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.

When I execute the command ssh localhost (in Ubuntu 10.10), it will display the error message "permission denied(public key)." What may be the problem?

Is there any problem in sshd_config file in /etc/ssh? Should PasswordAuthentication be set to no? I have set the PasswordAuthentication to no, but still it gives me the error "permission denied(publickey)."

share|improve this question
Did you disable password authentication in sshd_config? Why? What you are trying to do with this? –  ulidtko Apr 26 '11 at 8:47

3 Answers 3

you need to set file permissions right , try this ..

 $chmod go-w ~/
 $chmod 700 ~/.ssh
 $chmod 600 ~/.ssh/authorized_keys
share|improve this answer
@Volution2111Volution2111:thanks ya.. its worked fine now, I hv set the permissions.. –  priyaudupi Apr 27 '11 at 2:57
This is not a valid solution, it's a hack that depends on you having the same default configuration as the answerer. –  Statwonk Jul 13 '14 at 16:25


ssh-copy-id -i ~/.ssh/id_rsa.pub user@host

Or since you are on localhost try copyting your ssh key (rsa or dsa) inside a file $HOME/.ssh/authorized_keys

For key authentication in ssh you need to authorize your keys on host first AFAIK.

share|improve this answer
thanks –  priyaudupi Apr 26 '11 at 6:49
hey still it does not work ya.. what is the problem do u kw?? –  priyaudupi Apr 26 '11 at 7:26

Make sure you've installed "openssh-server" because it's not installed by default.

sudo apt-get install openssh-server

share|improve this answer
If it was not installed, OP would not get an error message at all, but hang. –  Lekensteyn Apr 26 '11 at 8:52

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.