LAST EDIT: Tuesday, May 13th, 2008

SSH: Create Private/Public Key Pair

An SSH key pair is needed to connect to an SSH server. Follow the instructions below to create a new key pair:

1. Install OpenSSH. On Ubuntu, you can install OpenSSH by opening your terminal and typing:

sudo apt-get install openssh-client

2. Once OpenSSH is installed, stay in the terminal and type:

ssh-keygen -t rsa

3. When prompted, press Enter to accept the default file name for your key.

4. Next, enter then confirm a password to protect your SSH key. Your key pair will be stored in ~/.ssh/ as id_rsa.pub [public key] and id_rsa [private key]

Next, you will need to copy the contents of id_rsa.pub to a file named authorized_keys and transfer the file to the target system you wish to connect to. Follow the instructions below:

1. Create the new file with the following command:

touch ~/.ssh/authorized_keys

2. Apply the correct permissions:

chmod 600 ~/.ssh/authorized_keys

3. Copy the contents of id_rsa.pub to the new file:

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

Finish by transferring the new file to the target server. You should now be able to connect to your SSH server.

Tagged with: ssh, ubuntu


Add Your Comment

Use the form below to add your comment. Markdown syntax is available. Note, comments are moderated by me for spam filtering. Alternatively, feel free to contact me privately.