Enable SSH Key Entry on Linux

When you run your servers on cloud, you cannot allow direct password login. Instead, you must add an SSH key to the server and share a copy of SSH key with clients. This will allow only authorized people connect to the servers.

Disable Password Authentication

You must first disable password based login on the server

vi /etc/ssh/sshd_config

change PasswordAuthentication from yes to no

Add SSH Key File

You must add the ssh key file to every linux user that you want to have direct access. For now, we are going to add the SSH key to root user

As root user

mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys

vi .ssh/authorized_keys

--> paste the ssh key, save and close

Restart ssh service on the server

systemctl restart sshd.service


Was this article helpful?

Related Articles

Leave a Comment