Configure SSH Key Authentication Only

Configure SSH Key Authentication Only

Configure CentOS SSH Key Autnentication Only

For this blog we are going to go over setting up a SSH server for key-only authentication. Here’s the basic process:

vi /etc/ssh/sshd_config on the SSH server

from here we need to edit the ssh config

Same screenshot: vi /etc/ssh/sshd_config to edit the SSH daemon config

un-comment lines 47, and 48

sshd_config lines 47-48 RSAAuthentication yes and PubkeyAuthentication yes

now generate the SSH keys via Linux

ssh-keygen -b 2048 -t rsa -C servername-key creating /root/.ssh/id_rsa

now set permissions to only allow root access to the keys

chmod 700 .ssh/ and chmod 600 .ssh/id_rsa

from here copy the key to a remote system, and verify you can login

view the public key using VI

vi .ssh/id_rsa.pub to view the public key

from here copy the encrypted string to another user account ,and vi the un-created “authorized_keys” file

vi .ssh/authorized_keys on the remote account

copy/paste into the file, save, and test to make sure you have passwordless authentication.

From here change line 64 in the SSHD config to no, make sure that keyless authentication works, otherwise you are oficially locked out after the next step.

sshd_config line 64 PasswordAuthentication no

now restart the ssh service

service sshd restart, Stopping and Starting sshd OK

That’s it!

Hosted Linux Servers at www.zwiegnet.com/go

Related guides: Allow SSH Connections Fedora 19 | Allow root SSH Login Amazon EC2

4 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *