Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have tried searching previous questions for answers to my question but all of the answers that have been suggested previously haven't worked for me.

I am trying to connect to a linode (running ubuntu 12.04 LTS) from my local machine (also running ubnutu 12.04 LTS)

I have create a private and public key on my local machine and copied my public key to my linode's authorized_keys file. However whenever I try to ssh to my linode I get the error message "Permission denied (publickey).

Its not a problem with how ssh is set up on my linode because I can ssh to it from my Windows machine using key authentication.

In my .ssh directory on my local ubuntu machine I have my id_rsa and id_rsa.pub files. Do I need to create an authorized_keys file on my local machine?

EDIT: This is what I get when I run ssh -vvv -i id_rsa [youruser]@[yourLinode]

debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).
share|improve this question
1) What do the logs on the SSH server say about the time you have this error on the client? (/var/log/auth.log) 2) How did you transfer the public key to the server? Always use ssh-copy-id to be sure about permissions. Your home directory, the .ssh directory and the authorized_keys file have strict permission requirements. (see manpage of sshd (8) on ~/.ssh/authorized_keys). 3) Did you generate a new keypair on Ubuntu? In case you reused the key from Windows - you'll have to convert it to OpenSSH format first. –  gertvdijk Jun 23 '13 at 1:13
The command should have been ssh -vvv -i .ssh/id_rsa .... (note the path to id_rsa!) - please replace - the old log only shows that "we" had no pubKey to send. –  guntbert Jun 23 '13 at 11:22
@guntbert I missed out the .ssh because I was already in the .ssh directory. I also tried it with .ssh/id_rsa but I got the same result –  Pattle Jun 23 '13 at 11:30
I see, so I misread - Please answer the questions from @gertvdijk. –  guntbert Jun 23 '13 at 11:40

4 Answers 4


Set up your client

  1. Generate your key
    • ssh-keygen
  2. Configure ssh to use the key
    • vim ~/.ssh/config
  3. Copy your key to your server
    • ssh-copy-id -i /path/to/key.pub SERVERNAME

Your config file from step 2 should have something similar to the following:

Hostname ip-or-domain-of-server
PubKeyAuthentication yes
IdentityFile ./path/to/key


  1. Make sure the server has your PUBLIC key (.pub).
  2. Make sure your IdentiyFile points to your PRIVATE key.
  3. Make sure your .ssh directory has 700 and your files are 700 permissions (rwx------).
  4. tail -f /var/log/auth.log (on the server) and monitor errors when you attempt to login
share|improve this answer

You don't need authorized_keys on your client.

You must tell the ssh-client to actually use the key you generated. There are several ways to do that. Just for testing type ssh -vvv -i .ssh/id_rsa [youruser]@[yourLinode]. You will have to provide your passphrase every time you want to connect to the server.

If that worked you can add the key to the ssh-agent with ssh-add .ssh/id_rsa (you will have to provide the passphrase only once for this and it should work as long as you don't logout/reboot)

share|improve this answer
Thanks for your help, I have edited my answer to show what happens when I type what you suggested. –  Pattle Jun 22 '13 at 23:22
to transfer a key, on the client, use ssh-copy-id –  bodhi.zazen Jun 23 '13 at 0:30
@bodhi.zazen Thanks, but I have already transferred the key, that isn't the problems –  Pattle Jun 23 '13 at 0:33
"You must tell the ssh-client to actually use the key you generated." No, by default it will look for the key in the default path, e.g. ~/.ssh/id_rsa. Also, the use of a key agent is completely optional and unrelated to the issue as far as I can see. –  gertvdijk Jun 23 '13 at 1:09
@gertvdijk, you are making assumptions here which are not backed by facts yet - we don't know what happened on the system. –  guntbert Jun 23 '13 at 11:24

I ran into this issue recently with my web server.

I typically keep a list of authorized keys on all my servers in ~/.ssh/authorized_keys2. From my experience, sshd will look for ~/.ssh/authorized_keys or ~/.ssh/authorized_keys2 by default.

In the case of my webserver, the /etc/ssh/sshd_config had this line

AuthorizedKeysFile    %h/.ssh/authorized_keys

instead of

AuthorizedKeysFile    %h/.ssh/authorized_keys2

I applied the latter, restarted my ssh daemon, and solved my problem logging in with ssh using my pubkey.

share|improve this answer

If all else failed, check that your login user belongs to the ssh's AllowedGroup. That is, your users is a member of the group shown at the following line in /etc/ssh/sshd_config on the server:

AllowGroups ssh #Here only users of 'ssh' group can login
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.