13

I just set up pubkey authentication on my server (running ubuntu server 10.10). If I am logged in to the server locally (at the box), then I can ssh into the server fine (from another machine). If I am not, however, I can not login and just receive the error "Permission denied (publickey)".

If I run the ssh command with the verbose flag, this is the output: http://pastebin.com/3bPaTe1u

I do not have this issue if I don't use pubkey authentication and just use password-based, but pubkey is the method I would like to use.

Any help?

  • 2
    Is your home encrypted? – Oli Apr 12 '11 at 22:21
  • 2
    Oli's question is quite relevant: if you encrypted your home directory, then the SSH daemon won't be able to read your public key when you aren't logged in. – James Henstridge Apr 12 '11 at 23:56
9

I'm going to assume your home directory is encrypted - in this case it is only decrypted when you log in - so when you are trying to authenticate you are not yet logged in so your home directory is not decrypted and hence as suggested above the ssh daemon can't read authorized keys file. You can fix this by following the instructions here.

0

Did you make sure that the entry in your /home/user/.ssh/id_rsa.pub local machine entry (the machine you're trying to SSH from) is copied correctly into the SSH server user's /home/user/.ssh/authorized_keys file? It must be copied in its entirety correctly in order for the system to recognize it on both the local system and the remote server (the server you're trying to SSH into)

  • 1
    Yes, as mentioned above I can ssh remotely if I am logged in locally at the same time. So I don't think that is the issue. – Jacob Millward Apr 12 '11 at 20:56
  • No, you misunderstand me. I mean in the client-to-server setup. Of course, from a connection directly on the server (i.e. being at the box), that's a given, you'll have access. I mean from your remote system. Did you make sure that the authorized_keys file is also owned by the right user and group? Did you make sure you didn't mis-paste? it wouldn't hurt to purge the authorized_keys file and try again. – Thomas Ward Apr 12 '11 at 21:00
  • The other alternative is that you have a slightly messed ssh system, but that's less likely – Thomas Ward Apr 12 '11 at 21:01
  • 1
    Just copied it over again, making sure that all the permissions are set etc. Still the same issue - I can log in with the keys if I am also logged in at the box, but not if It is JUST remotely. – Jacob Millward Apr 12 '11 at 21:14
  • 1
    hm. that sounds like the issue I had a long time ago with a borked openssh install. did you try reinstalling openssh-server by doing sudo apt-get purge openssh-server; sudo apt-get install openssh-server, just to make sure the install you have isn't broken or damaged? – Thomas Ward Apr 12 '11 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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