Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

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?

share|improve this question
Is your home encrypted? – Oli Apr 12 '11 at 22:21
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
up vote 5 down vote accepted

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.

share|improve this answer
I didn't follow those instructions, but I completely forgot that I had encrypted my home folder. Thanks a lot! – Jacob Millward Apr 13 '11 at 10:05
These instructions worked for me… – David Xia Jan 10 '13 at 15:36

Did you make sure that the entry in your /home/user/.ssh/ 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)

share|improve this answer
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
Further, the reason I don't think its copied over correctly is because it is denying your pubkey. If you copied it over correctly and put it on its own line in the authorized_keys file, it should not be denying you access. – Thomas Ward Apr 12 '11 at 21:10
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

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.