I have two servers where I connect using SSH public key authentication, with different keys. The configuration looks like this:
Host server1
IdentityFile /path/to/key
IdentitiesOnly yes
Host server2
IdentityFile /path/to/other/key
IdentitiesOnly yes
I add the two keys to the agent and verify via ssh-add -l
that both are present. Yet, one works but the other does not:
$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':
The OS is Ubuntu 14.04, the output of ssh -V
is OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3, OpenSSL 1.0.1f 6 Jan 2014
.
ssh-add -l
that both are present.RSA
in openssh format or somepem
? There must be some difference.-----BEGIN RSA PRIVATE KEY-----
, some properties, a big block of base64 data,-----END RSA PRIVATE KEY-----
.