Generating SSH Keys - Generating a key
Written by Sam Moffatt   
Tuesday, 16 October 2007 05:15
Article Index
Generating SSH Keys
Generating a key
Transferring your key
Using an SSH Agent
Keychain and SSH
SSH and GNOME
Wrapping Up
All Pages

Generating a key

On your local machine if you haven't already got a ".ssh" folder in your home directory and change to this directory. This directory is where SSH keeps track of your private keys, authorized public keys and known hosts. Your private keys are used by SSH to login into servers where your public keys are stored and the known hosts file stores the identifier of all of the servers you have connected to so you can verify that that haven't been altered or are being redirected some how (this why it prompts you when you connect to a new host if you want to trust the host).

To generate the key we use ssh-keygen, in this case we're going to generate a RSA key: ssh-keygen -b 1024 -t rsa

This will result in the following output:

moffats@shadow:~/.ssh> ssh-keygen -b 1024 -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/moffats/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/moffats/.ssh/id_rsa.
Your public key has been saved in /home/moffats/.ssh/id_rsa.pub.
The key fingerprint is: 28:08:8b:d9:50:a4:83:b6:51:69:d4:ab:9a:ae:25:c1
moffats@shadow moffats@shadow:~/.ssh>

Since we're going to be creating a new key for ourselves we can accept the default file to save the key but we will want to specify our own passphrase. A passphrase is used to 'unlock' the key before it is used and will be equivalent to your password.



Last Updated on Wednesday, 09 April 2008 06:57