Wednesday, April 1, 2020

Back to third grade with SSH or how to setup ~/.ssh/authorized_keys

Very often I am asked to SSH to a machine just to hit access denied. A few roundtrips then needed until issue is resolved. Here are my commands to get it working from the first time.

# mkdir .ssh
# vi .ssh/authorized_keys # add user's public key here
# chown -R user.user .ssh
# chmod 700 .ssh
# chmod 600 .ssh/authorized_keys
# restorecon -R .ssh

Last one is for SELinux enabled distributions.

Hope you find useful.