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 a server setup where I can ssh to from my mac. The setup is made with a trusted key and it works perfect. But whenever I reboot the server and I that try to login using ssh my_user@ip then it says: Permission denied (publickey). However if I physically go to the server and log in as my_user, then suddenly I can get remote access by ssh from my mac as well. What do I need to change in my setup?

share|improve this question
3  
Are you using an encrypted home directory by chance? –  bodhi.zazen Feb 13 '13 at 19:28
    
I'm pretty sure that I did so when installing yes... –  Niels Kristian Feb 13 '13 at 20:03
add comment

1 Answer

up vote 3 down vote accepted

Well, the problem is that the key is stored in ~/.ssh/authorized_keys

With an encrypted home, you can not log in with the key as your home directory is encrytped.

Move authorized keys to somewhere else, I personally use /etc/ssh/.authorized_keys

You then edit /etc/ssh/sshd_config , add/edit the line

AuthorizedKeysFile /etc/ssh/.authorized_keys

Restart ssh server.

See also:

http://manpages.ubuntu.com/manpages/precise/en/man5/sshd_config.5.html

share|improve this answer
    
I disagree that a single file should be used, this is why man sshd_config describes placeholders such as %u for the AuthorizedKeysFile option. –  0xC0000022L Feb 13 '13 at 20:11
    
    
@0xC0000022L - It is less then ideal, but, %u is not going to work with encrypted home directories. You may list multiple files if you wish, see the man page. –  bodhi.zazen Feb 13 '13 at 20:16
    
@bodhi.zazen: You mean SSH can't deduce the username from the connection attempt? I realize that %h won't work, but I think I even got it to work with %u on a Ubuntu Desktop install, although this was 10.04 or so. –  0xC0000022L Feb 13 '13 at 20:18
    
%u should work, do as you wish ;) –  bodhi.zazen Feb 13 '13 at 20:21
add comment

Your Answer

 
discard

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.