我有两台服务器,使用 SSH 公钥身份验证进行连接,但密钥不同。配置如下:
Host server1
IdentityFile /path/to/key
IdentitiesOnly yes
Host server2
IdentityFile /path/to/other/key
IdentitiesOnly yes
我将两个密钥添加到代理并通过ssh-add -l
以下方式验证它们都存在。然而,一个有效,另一个无效:
$ssh -v server1
...
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /path/to/key
debug1: Server accepts key: ...
debug1: Authentication succeeded (publickey).
$ssh -v server2
...
debug1: Next authentication method: publickey
debug1: Trying private key: /path/to/other/key
debug1: key_parse_private2: missing begin marker
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/path/to/other/key':
操作系统是Ubuntu 14.04,的输出ssh -V
是OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3, OpenSSL 1.0.1f 6 Jan 2014
。