Reset authorized_keys permissions

Last updated July 23, 2019 | e4a001f

Sometimes, you might find you are having odd issues using public keys on a Linux server. I usually end up editing files under the wrong account and mess up permissions.

The solution might be to run this one-liner (really an adaptation of multiple commands, one-liner is a questionable name for this) as the user who you’re trying to log in to the server as (probably not root):

chmod 700 $HOME/.ssh && chmod go-w $HOME $HOME/.ssh && chmod 600 $HOME/.ssh/authorized_keys && chown `whoami` $HOME/.ssh/authorized_keys