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

or

ssh-keygen -t rsa -b 4096

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

copy the content of id_rsa.pub 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

[root@sangv.info ~]# cd /root/.ssh
[root@sangv.info ~]#scp ids_rsa.pub root@remoteip:/root/.ssh/authorized_keys

or if you want more shortcut

[root@sangv.info ~]#ssh-keygen -f /root/.ssh/id_rsa -t rsa -N ''
[root@sangv.info ~]#scp /root/.ssh/ids_rsa.pub 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 ,

[root@sangv.info ~]# cat /root/.ssh/known_hosts

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

[root@sangv.info ~]# ssh-keygen -R "hostname or IP "


sangv. Info