So a few months ago I setup key based login on my server so that it only accepts key based logins. No passwords ever. For my main user I have a key which I keep in my .ssh folders so I can login to it.
I now have the need for a 2nd user to have a login and after a bit of searching found these instructions on how to create a key (I assume I did something similar since I did this months ago and I can't remember the exact steps)
I've followed the instructions however I can't connect as the new user.
I copy id_rsa and id_rsa.pub into my .ssh folder onto the client machine (after I temporarily renamed the original id_rsa) and tried to connect but I keep getting:
Permission denied (publickey).
Here is a debug output of when I attempt to SSH in:
OpenSSH_6.2p1, OpenSSL 1.0.1e 11 Feb 2013
debug1: Connecting to direct.MYURL.com [209.XX.XX.XX] port 22.
debug1: Connection established.
debug1: identity file /home/username/.ssh/id_rsa type 1
debug1: identity file /home/username/.ssh/id_rsa-cert type -1
debug1: identity file /home/username/.ssh/id_dsa type -1
debug1: identity file /home/username/.ssh/id_dsa-cert type -1
debug1: identity file /home/username/.ssh/id_ecdsa type -1
debug1: identity file /home/username/.ssh/id_ecdsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.8p1 Debian-1ubuntu3
debug1: match: OpenSSH_5.8p1 Debian-1ubuntu3 pat OpenSSH_5*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: RSA AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA
debug1: Host 'direct.myurl.com' is known and matches the RSA host key.
debug1: Found key in /home/username/.ssh/known_hosts:6
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/username/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/username/.ssh/id_dsa
debug1: Trying private key: /home/username/.ssh/id_ecdsa
debug1: No more authentication methods to try.
I feel like I'm missing something obvious here but can't figure it out.
Best Answer
You have to give each key an unique name. You are having a problem as you new key has the same name as the old key.
See http://bodhizazen.com/Tutorials/SSH_keys#Generate