0

I have generated private-public pair of ssh keys using e.g. this. I don't have access to the remote server, so I sent the public key to someone that possess an account there.

The public key was placed in the directory ~/.ssh/authorized_keys. Now I want to access using my private keys:

ssh -i ./authorized_keys/id_rsa usr@location

or

ssh usr@location

requests the usr password and does not pick the public key. How can I fix this? Verbose mode says that it can use the key, but it doesn't use it (tail of the output using the first option)

...
debug1: Next authentication method: publickey
debug1: Offering public key: .ssh/authorized_keys/id_rsa RSA   SHA256:XXX/XXXXXXXX explicit agent
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: password

1 Answer 1

2

The public key was placed in the directory ~/.ssh/authorized_keys.

This should not be a directory. On the server side it must be a file containing one public key per line. On the client side it has no special meaning, but it's a great way to completely confuse yourself two months later.

requests the usr password and does not pick the public key. How can I fix this? Verbose mode says that it can use the key, but it doesn't use it (tail of the output using the first option)

Most likely, the key is not used because the server has not accepted it.

As people often have multiple keypairs, SSH publickey authentication is a two-step process: first the client offers its public key (that is, it offers all of your keys, one by one), and if the server finds that key acceptable then the client sends a "proof" signature made using the private key.

If the public key is not found in the server's authorized_keys file, it rejects the offer and the client may continue offering another. (This way, someone with 10 keys doesn't need to type 10 decryption passphrases all at once.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .