SSH key in authorized_keys will only work sometimes

I’ve been dealing with this for the last couple days but only this morning realized that there was another fact I wasn’t including in my Google searches for “ssh not using key”: that my home directory on this particular box was encrypted.

(Below text from

If you have an encrypted home directory, SSH cannot access your authorized_keys file because it is inside your encrypted home directory and won’t be available until after you are authenticated. Therefore, SSH will default to password authentication.

To solve this, create a folder outside your home named /etc/ssh/<username> (replace “<username>” with your actual username). This directory should have 755 permissions and be owned by the user. Move the authorized_keys file into it. The authorized_keys file should have 644 permissions and be owned by the user.

Then edit your /etc/ssh/sshd_config and add:

AuthorizedKeysFile    /etc/ssh/%u/authorized_keys

Finally, restart ssh with:

sudo service ssh restart

The next time you connect with SSH you should not have to enter your password.

Revision List

#1 on 2016-Feb-25 Thu  02:06+-25200