Showing posts with label generating keys in ssh. Show all posts
Showing posts with label generating keys in ssh. Show all posts

Friday, June 14, 2013

Generate ssh keys

Setting up SSH public/private keys

There are two types of keys in ssh :

a) Public keys &
b) Private keys

RSA & DSA are two most popular public key cryptography algorithm.
RSA was named after the initials of its co-founders, Rivest, Shamir and Adleman.
DSA is Digital Signature Algorithm.

Difference between DSA & RSA :
DSA is faster in signing, but slower in verifying. A DSA key of the same strength as RSA (1024 bits) generates a smaller signature. An RSA 512 bit key has been cracked, but only a 280 DSA key.

Path of Public & Private keys file :
If you are root
Public key file :  /root/.ssh/id_dsa.pub or /root/.ssh/id_rsa.pub
Private key file : /root/.ssh/id_dsa or /root/.ssh/id_rsa

If you are user
Public key file :  /home/user/.ssh/id_dsa.pub or /home/user/.ssh/id_rsa.pub
Private key file : /home/user/.ssh/id_dsa or /home/user/.ssh/id_rsa

Generate Public keys : dsa

# ssh-keygen -t dsa



Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
c9:a7:51:72:2b:e1:58:be:2a:12:53:41:28:03:e2:3e root@user-To-be-filled-by-O-E-M
The key's randomart image is:
+--[ DSA 1024]----+
|+  o.            |
|= . .            |
| +   .  + o      |
|.   .  * * .     |
| E .  . S o      |
|  +      *       |
|   o    o        |
|  . .  .         |
|   . ..          |

+-----------------+

In your .ssh directory
id_dsa.pub is public key file & id_dsa is private key file.

Generate Public keys : rsa

# ssh-keygen -t rsa


Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
44:ba:dc:d2:e1:f8:27:27:db:c0:e8:e5:21:31:43:2d root@user-To-be-filled-by-O-E-M
The key's randomart image is:
+--[ RSA 2048]----+
|        .        |
|       +         |
|      E +        |
|     o O .       |
|      O S        |
|       O         |
|      o O o      |
|     . + X       |
|      . o .      |
+-----------------+



In your .ssh directory
id_rsa.pub is public key file & id_rsa is private key file

NOTE :

You need either RSA or DSA key. You do not need to generate both.