Today, I’m trying to setup ssh key authentication, so I can ssh into my server without typing password.
What caught me is that I can’t get key authentication working for the non-root user on server.
For example, I have user client
on my client and user server
and root
on my server.
client@client # ssh server@server
client@client # ssh root@server
I googled it and found the reference here
To sum it up:
On client machine, generate key-pair
ssh-keygen -t rsa
Copy the content of .ssh/id_rsa.pub
to /root/.ssh/authorized_keys
and /home/server/.ssh/authorized_keys
On server machine, modify /etc/ssh/sshd_config
, uncomment
RSAAuthentication yes
PubkeyAuthentication yes
THIS STEP IS VERY IMPORTANT!!!
Make sure file permissions on a user’s /home/server/.ssh
directory must be 700
, and the /home/server/.ssh/authorized_keys
must be 600
On server machine, systemctl restart sshd