为什么我的 SSH 会话仅提示输入一台主机的密码?

为什么我的 SSH 会话仅提示输入一台主机的密码?

我的环境中所有 SSH 连接都通过跳线盒。有很多 Linux 服务器,但要访问它们,我必须先通过 ssh 连接到 bastien 主机。

一台特定内部主机不断提示输入密码

firewall ~ $ ssh m4
Password:

但从 elswehere 到 m4 的连接可以通过密钥验证正常工作。

/var/log/secure没有帮助,没有错误。

 Jul 27 21:34:57 m4 sshd[29240]: pam_unix(sshd:session): session opened for user root by (uid=0)
 Jul 27 21:34:57 m4 sshd[29236]: Accepted keyboard-interactive/pam for root from firewall[192.168.9.248] port 4097 ssh2

 but from another host, pubkey works fine
 Jul 27 21:34:57 m4 sshd[29240]: Accepted publickey for root from m3[192.168.9.9] port 6090 ssh2

为什么 SSH 会提示输入该组合的密码而不是其他组合的密码?

答案1

我跑去ssh-add -L确认我的钥匙已加载

 firewall ~ $ ssh-add -L
 ssh-rsa AAAAB3NzaC1yc2EAA.....snip.....VBQ== rsa-key-20170210
 etc...

然后我跑去ssh -v m4看看 SSH 认为发生了什么......我灵光一现。

 firewall ~ $ ssh m4 -v
 OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
 debug1: Reading configuration data /root/.ssh/config
 debug1: /root/.ssh/config line 11: Applying options for m4
 debug1: Reading configuration data /etc/ssh/ssh_config
 debug1: /etc/ssh/ssh_config line 56: Applying options for *
 debug1: Connecting to m4 [192.168.9.74] port 22.
 debug1: fd 3 clearing O_NONBLOCK
 debug1: Connection established.
 debug1: permanently_set_uid: 0/0
 debug1: identity file /root/.ssh/id_rsa type 1
 ...snip
 debug1: Enabling compatibility mode for protocol 2.0
 debug1: Local version string SSH-2.0-OpenSSH_6.6.1
 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
 debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
 debug1: SSH2_MSG_KEXINIT sent
 debug1: SSH2_MSG_KEXINIT received
 debug1: kex: server->client aes128-ctr hmac-sha1 none
 debug1: kex: client->server aes128-ctr hmac-sha1 none
 debug1: kex: diffie-hellman-group-exchange-sha256 need=20 dh_need=20
 debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<7680<8192) sent
 debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
 debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
 debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
 debug1: Server host key: RSA 23:87:00:00:00:00:00:00:N0:N0:N0
 debug1: Host 'm4' is known and matches the RSA host key.
 debug1: Found key in /root/.ssh/known_hosts:1869
 debug1: ssh_rsa_verify: signature correct
 debug1: SSH2_MSG_NEWKEYS sent
 debug1: expecting SSH2_MSG_NEWKEYS
 debug1: SSH2_MSG_NEWKEYS received
 debug1: SSH2_MSG_SERVICE_REQUEST sent
 debug1: SSH2_MSG_SERVICE_ACCEPT received
 debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
 debug1: Next authentication method: gssapi-keyex
 debug1: No valid Key exchange context
 debug1: Next authentication method: gssapi-with-mic
 debug1: Unspecified GSS failure.  Minor code may provide more information
 No Kerberos credentials available (default cache: KEYRING:persistent:0)

 debug1: Unspecified GSS failure.  Minor code may provide more information
 No Kerberos credentials available (default cache: KEYRING:persistent:0)

 debug1: Next authentication method: keyboard-interactive
 Password:  ^C

这句话debug1: /root/.ssh/config line 11: Applying options for m4引起了我的注意 - 不应该有任何针对该主机的特定内容。

 Host 10.99.2.23       # m4 drac
    PasswordAuthentication=yes
    PubkeyAuthentication=no

因此,物理主机是 Dell 服务器,并具有用于控制台访问的专用 OOB 端口。戴尔将此称为 DRAC 端口,并且我设置了 DNS 记录m4-drac

DRAC 未配置为使用 SSH 公钥进行身份验证,因此此配置会阻止其尝试。但配置已应用于主机名米4因为它不尊重哈希值。

回答ssh 的 .config 文件不会将哈希值视为注释分隔符。

相关内容