System Administration: Creating a Public/Private Key Pair
- - Open your favourite terminal application
- - Run the key generation program:
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key(/home/user/.ssh/id_rsa):
- - Enter the path that you want to store the file that will hold the key:
By default, the file name id_rsa, which represents an RSA v2 key (as specified in the command above), appears in parentheses.
You can select this file by pressing Return. Or, you can type an alternative filename.
- - Enter a passphrase that will need to be entered every time you want to use your key. If you're going to use the key for scripting purposes, just press Return to use a blank passphrase:
Enter passphrase(empty for no passphrase):
- - Re-enter the passphrase to confirm it:
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
- - The public key name is created automatically and the string .pub is appended to the private key name and stored in the location you provided above. If, however, you chose the default, the file will be stored in your home directory under a hidden folder called .ssh.
If, however, you are using Windows, you can either go through the rigmarole of installing Linux for Windows, or you can create your public/private key pair using the following instructions based on PuTTY. PuTTY is an SSH client for Windows. It comes with a utility program called PuTTYgen which you can use to generate SSH key pairs.
You can download the PuTTY installer from www.chiark.greenend.org.uk. Once downloaded and installed:
- - Open the PuTTYgen utility (Start Menu => All Programs => PuTTY => PuTTYgen):
- - Make sure that RSA is selected and press Generate.
- - Save your public and private keys to your computer.
Now that you have created your key pair, the public key can be shared or uploaded anywhere, but your private key should only be stored on personal devices that you and only you control.