fir3net
PPS-Firenetbanner-780.5x190-30-03-17

Using SSH Keys - Video Tutorial

Using ssh keys instead of password authentication allows you to speed up and automate your SSH logins. Ideal for for scripts that require you copy files etc. Below shows you the steps on how to set up SSH Keys. The commands that were run within the video tutorial are :

Server

[root@server ~]# ls -lha ~/.ssh
[root@server ~]# ssh root@127.0.0.1

Client

[root@client ~]# ssh-keygen -t rsa
[root@client ~]# scp /root/.ssh/id_rsa.pub This email address is being protected from spambots. You need JavaScript enabled to view it.:/root/.ssh/authorized_keys
[root@client ~]# ssh This email address is being protected from spambots. You need JavaScript enabled to view it. 

 

 

Debugging

There are a number of reasons why your SSH-Keys may fail to connect you.
To debug sshd and ssh so that you can find the root cause run the following commands. We run the run the ssh daemon to listen on port 1234 so that we don't have to stop the existing sshd process.

Server

[root@server ~]# /usr/sbin/sshd -d -p 1234

Client

root@client ~]# ssh -vvv -p 1234 root@[server ip address]


A common cause of issues is permission issues. Ensure that '/admin/.ssh/authorized_keys' is set with permissions 600.
Also if you are connecting as another user you will need to edit '/etc/ssh/sshd_config' and add your user to the line that starts with 'AllowUsers'

Additional Resources : 

About the Author

RDonato

R Donato

Rick Donato is the Founder and Chief Editor of Fir3net.com. He currently works as a Principal Network Security Engineer and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001