Generate SSH key in Linux
You can generate SSH key pair in Linux using the ssh-keygen command.
You will be asked for a file in which the key should be saved and passphrase (same as password) for the key.
whb@host: ssh-keygen -t dsa Generating public/private dsa key pair. Enter file in which to save the key (/home/whb/.ssh/id_dsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in id_dsa. Your public key has been saved in id_dsa.pub. The key fingerprint is: 11:9e:ef:f2:14:a9:b9:c8:32:9c:b1:c3:c1:f5:d5:61 whb@host
This will create a private key saved in /home/whb/.ssh/id_dsa and a public key saved in /home/whb/.ssh/id_dsa.pub
The passphrase is used every time you connect via SSH.
[alert style="danger"]You should never disclose your private SSH key. It’s only legitimate to ask for a public SSH key, it is absolutely safe to provide it.[/alert]
Was this article helpful?