Thursday, September 4, 2014

SHH key pair generation

How to generate an ssh key pair

let 's suppose that you want to generate an ssh key in order to connect to the machine called "enigma".

1. Generating the key

[root@enigma ~]# cd /root/.ssh
[root@enigma .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): enigma_key
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in enig_key.
Your public key has been saved in enigma_key.pub.
The key fingerprint is: 91:c3:d9:ed:82:38:10:bc:28:d8:27:6b:04:ea:08:be root@enigma


Two files are created:
private key enigma_key, you can rename it to enigma_key.pem
public key: enigma_key.pub

2. Authorizing the generated key to connect to enigma

Append the content of enig_key.pub to /root/.ssh/authorized_keys
you can now use enigma_key.pem to connect to enigma from another machine.