How to Generate SSH Keys on Linux System

Posted in Linux May 30, 2018

This is a quick Tutorial how you can generate ssh keys and have SSH connection with remote server ,

To generate the SSH key you can have any of the following Command Lines

ssh-keygen -t rsa


ssh-keygen -t rsa -b 4096

It shall generate two keys as id_rsa and in your default location /root/.ssh

copy the content of into remote server and save in cd /root/.ssh/authorized_keys

Now You shall be able to login directly using ssh 

ssh root@serverip/serverdomain

or If you are really lazy to do it manually you can do it in one go

[ ~]# cd /root/.ssh
[ ~]#scp root@remoteip:/root/.ssh/authorized_keys

or if you want more shortcut

[ ~]#ssh-keygen -f /root/.ssh/id_rsa -t rsa -N ''
[ ~]#scp /root/.ssh/ root@remoteip:/root/.ssh/authorized_keys

I got some Bonus Tutorials for your information

When ever there is a successful SSH connection there will be records that will be stored with in your local folder so, you can view it in a known_hosts file ,

[ ~]# cat /root/.ssh/known_hosts

If you want to remove these records ,manually you can use this cheat, to remove records in known_hosts

[ ~]# ssh-keygen -R "hostname or IP "

sangv. Info