接受任何 SSH 连接,无论客户端密钥是什么

接受任何 SSH 连接,无论客户端密钥是什么

假设我正在设置一个蜜罐,设置 SSHD 以接受任何连接的最快方法是什么?是的,这确实不安全,所以请不要复制 :-)

可能会有用(放在堆栈pam_permitauth)...我只是对 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

并且为了保险起见,该帐户还设置了密码(否则将被视为禁用)。

相关内容