![接受任何 SSH 连接,无论客户端密钥是什么](https://linux22.com/image/639191/%E6%8E%A5%E5%8F%97%E4%BB%BB%E4%BD%95%20SSH%20%E8%BF%9E%E6%8E%A5%EF%BC%8C%E6%97%A0%E8%AE%BA%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%AF%86%E9%92%A5%E6%98%AF%E4%BB%80%E4%B9%88.png)
假设我正在设置一个蜜罐,设置 SSHD 以接受任何连接的最快方法是什么?是的,这确实不安全,所以请不要复制 :-)
可能会有用(放在堆栈pam_permit
上auth
)...我只是对 PAM 没有太多经验,目前正在阅读文档。
https://unix.stackexchange.com/questions/124187/accept-any-private-key-for-authentication
对于实际问题的一些背景,我有一台位于防火墙后面的客户端计算机,它尝试通过首先连接出站来设置反向 SSH 隧道(以便我可以重新连接它)...虽然它确实继续尝试连接,但就好像它使用的密钥不再有效(这很奇怪)或其他地方出现故障。
服务器日志显示客户端关闭了连接,其他客户端可以正常连接......
debug1: Forked child 29472.
Set /proc/self/oom_score_adj to 0
debug1: rexec start in 5 out 5 newsock 5 pipe 7 sock 8
debug1: inetd sockets after dupping: 3, 3
Connection from CLIENT_IP port 46186
debug1: Client protocol version 2.0; client software version OpenSSH_6.0p1 Debian-4+deb7u2
debug1: match: OpenSSH_6.0p1 Debian-4+deb7u2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u2
debug1: permanently_set_uid: 105/65534 [preauth]
debug1: list_hostkey_types: ssh-rsa,ssh-dss [preauth]
debug1: SSH2_MSG_KEXINIT sent [preauth]
debug1: SSH2_MSG_KEXINIT received [preauth]
debug1: kex: client->server aes128-ctr hmac-md5 none [preauth]
debug1: kex: server->client aes128-ctr hmac-md5 none [preauth]
debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
debug1: SSH2_MSG_NEWKEYS sent [preauth]
debug1: expecting SSH2_MSG_NEWKEYS [preauth]
debug1: SSH2_MSG_NEWKEYS received [preauth]
debug1: KEX done [preauth]
debug1: userauth-request for user tunnel service ssh-connection method none [preauth]
debug1: attempt 0 failures 0 [preauth]
debug1: PAM: initializing for "tunnel"
debug1: PAM: setting PAM_RHOST to "server"
debug1: PAM: setting PAM_TTY to "ssh"
debug1: userauth-request for user tunnel service ssh-connection method publickey [preauth]
debug1: attempt 1 failures 0 [preauth]
debug1: test whether pkalg/pkblob are acceptable [preauth]
debug1: Checking blacklist file /usr/share/ssh/blacklist.DSA-1024
debug1: Checking blacklist file /etc/ssh/blacklist.DSA-1024
debug1: temporarily_use_uid: 1001/1001 (e=0/0)
debug1: trying public key file /home/tunnel/.ssh/authorized_keys
debug1: fd 4 clearing O_NONBLOCK
debug1: restore_uid: 0/0
debug1: temporarily_use_uid: 1001/1001 (e=0/0)
debug1: trying public key file /home/tunnel/.ssh/authorized_keys2
debug1: Could not open authorized keys '/home/tunnel/.ssh/authorized_keys2': No such file or directory
debug1: restore_uid: 0/0
Failed publickey for tunnel from CLIENT_IP port 46186 ssh2
Connection closed by CLIENT_IP [preauth]
debug1: do_cleanup [preauth]
debug1: monitor_read_log: child log fd closed
debug1: do_cleanup
debug1: PAM: cleanup
debug1: Killing privsep child 29473
答案1
这有效......但是因为这基本上删除了所有形式的身份验证,请不要这样做......
/etc/pam.d/sshd
auth required pam_permit.so
auth
以(又称模块)开头的任何其他行都被注释掉了……您还应该检查所有@include
行,因为它们可能包含设置进一步auth
模块的文件,例如
#@include common-auth
然后我必须确保 SSHD 配置没有设置以下任何一项:
/etc/ssh/sshd_config
# PasswordAuthentication no
# ChallengeResponseAuthentication no
# GSSAPIAuthentication no
# UsePAM no
并且为了保险起见,该帐户还设置了密码(否则将被视为禁用)。