I'm running a simple command on two separate machines:
ssh -vvvT git@github.com
On one machine, this works. On the other machine, ssh fails with these messages:
debug1: Server accepts key: pkalg ssh-rsa blen 535
debug2: input_userauth_pk_ok: fp bd:5a:d9:2b:d0:36:1c:f1:dc:f8:83:05:17:b9:04:e0
debug3: sign_and_send_pubkey: RSA bd:5a:d9:2b:d0:36:1c:f1:dc:f8:83:05:17:b9:04:e0
debug1: key_parse_private2: missing begin marker
debug1: key_parse_private_pem: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug2: no passphrase given, try next key
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).
I am using the same private key on both machines. The private key has the begin marker (i.e. -----BEGIN RSA PRIVATE KEY-----). The private key was generated without a passphrase. The permissions for the .ssh directory are the same on both machines (700). The permissions for the private key file are the same on both machines (600). Here's the contents of my .ssh/config:
Host github.com
StrictHostKeyChecking no
IdentityFile ~/keyfile
I'm completely confused on why the output says "missing begin marker", why it's attempting to read a passphrase, and of course why it's failing at all. Is there anything I should try to help diagnose this issue?
There's no marker on a key file indicating it has a passphrase. When ssh reads a key from a file, it first tries to interpret the file contents without a passphrase. If it can't make sense of the file's contents, it'll ask for a passphrase and try reading the file again. You can feed ssh a complete nonsense file, and it'll ask for a passphrase before giving up on it:
$ head -1500c < /dev/urandom > boguskey
$ chmod 600 boguskey
$ ssh -i boguskey localhost
Enter passphrase for key 'boguskey':
In other words, if ssh is prompting you for a passphrase, and you're confident the file isn't supposed to have a passphrase, then there must be something else wrong with the file. It may be truncated or corrupt, for example.