How to generate SSH key in Linux/Unix ?
To generate SSH key in Linux/Unix we use ssh-keygen tool . It is used to generate SSH keys that help us to manage SSH authentication.
The ssh-keygen tool generate the public and private key . By default , the public stores in $HOME/.ssh/id_rsa.pub and the private key stores in $HOME/.ssh/id_rsa file location .
$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/sekar/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/sekar/.ssh/id_rsa. Your public key has been saved in /home/sekar/.ssh/id_rsa.pub. The key fingerprint is: f9:a5:8a:04:4e:a6:3b:3b:ff:05:10:61:fe:8e:f1:2f sekar@rathna-Satellite-C850 The key's randomart image is: +--[ RSA 2048]----+ | +. | | o . | | o | | o . | | = o S . | | = * . . o | | . o + . o | | o. .E+ . | | o=..o.o | +-----------------+
In the above example, After hitting ssh-keygen and enter it will ask for location of rsa key file to be saved. You can leave it empty to save the file in its default location $HOME/.ssh/id_rsa . Then it ask for passphrase , here you need to type your passphrase and confirm it by re-enter the same passphrase . If you leave it empty then it consider as no passphrase .
You can verify your generated SSH public/private key as below .