Why am I being prompted for my password after setting up SSH keys?

I am trying to set up RSA keys so I can make an RSYNC script.

Box boxes are Ubuntu 16.04

What I have done

generated RSA keys on main server (No, I didn't enter a passphrase)

sftp public key to backup server

moved public key into ~/.ssh/authorized_keys

Changed lines in sshd_config

****PubkeyAuthentication yes

AuthorizedKeysFile .ssh/authorized_keys****

chmod 700 .ssh/

chmod 600 /ssh/authorized_keys

restart ssh daemon

When I try to ssh into the backup server from the main server, I still get prompted for a password.

output of ssh -v is:

debug1: Found key in /root/.ssh/known_hosts:1

debug1: rekey after 134217728 blocks

debug1: SSH2MSGNEWKEYS sent

debug1: expecting SSH2MSGNEWKEYS

debug1: rekey after 134217728 blocks

debug1: SSH2MSGNEWKEYS received

debug1: SSH2MSGEXT_INFO received

debug1: kexinputextinfo: server-sig-algs= debug1: SSH2MSGSERVICEACCEPT received

debug1: Authentications that can continue: publickey,password

debug1: Next authentication method: publickey

debug1: Offering RSA public key: /root/.ssh/id_rsa

debug1: Authentications that can continue: publickey,password

debug1: Trying private key: /root/.ssh/id_dsa

debug1: Trying private key: /root/.ssh/id_ecdsa

debug1: Trying private key: /root/.ssh/id_ed25519

debug1: Next authentication method: password

Anybody have any ideas?

SOLVED Okay, I'm an idiot. The mistake I made was making a directory .ssh/authorizedkeys. authorized keys is supposed to be a file, not a directory. So, to fix it I moved my key out of .ssh/authorizedkeys, deleted .ssh/authorized keys. Then, I renamed my key to authorized_keys (mv command). Future keys have to be appended to the file.

In short .ssh/authorized_keys shouldn't be a directory, but rather a file.

1 Reply

In case any one else run into this: use ssh-copy-id to copy the public key.

$ ssh-copy-id user@remote-host

If you have multiple keys and want to specify which one to copy use "-i id_file".

So much easier and less chance of mistakes like this.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct