I use SSH to connect to a machine. There is no password access, only an existing SSH key which works.
I need to create a new key (production.key, production.key.pub) which I did like this, without choosing a passphrase:
cd /home
sudo ssh-keygen -t rsa
I then copied the public key to the machine like this:
cat /home/production.key.pub | ssh -i /home/old_key user@<IP> "cat >> /root/.ssh/authorized_keys"
I then tried to log in like this:
ssh -i /home/production.key user@<IP>
But I still get a password prompt. So I tried again with sshd in debug mode, and got this output:
debug1: matching key found: file /root/.ssh/authorized_keys, line 2 RSA XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
debug1: restore_uid: 0/0
Postponed publickey for root from XX.XX.XX.XX port 60407 ssh2 [preauth]
debug1: userauth-request for user root service ssh-connection method password [preauth]
What am I doing wrong? Why do I still get a password prompt when it says 'matching key found'? How do I fix this?
I fixed this by changing the permissions on the private key from 600 to 644:
sudo chmod 644 /home/production.key