How To SSH

Step 1: Create the RSA key pair on the connecting (client) computer

ssh-keygen -t rsa

You’ll be asked where to save the key. ‘~/.ssh/id_rsa’ is the default.

The entire keygen process should look similar to this:

ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/demo/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/demo/.ssh/id_rsa.
Your public key has been saved in /home/demo/.ssh/
The key fingerprint is:
4a:dd:0a:c6:35:4e:3f:ed:27:38:8c:74:44:4d:93:67 demo@a
The key's randomart image is:
+--[ RSA 2048]----+
|          .oo.   |
|         .  o.E  |
|        + .  o   |
|     . = = .     |
|      = S = .    |
|     o + = +     |
|      . o + o .  |
|           . o   |
|                 |

The public key is now located in ~/.ssh/ The private key (identification) is now located in ~/.ssh/id_rsa.

Step 2: Add server to your ~/.ssh/config file

Open ~/.ssh/config and add an entry for the server you want to share this key with.

The config file entry should look similar to this:

Host demoserver
	User theatomheart
	Port 22
	IdentityFile ~/.ssh/id_rsa

Step 3: Copy the public key to the server

ssh-copy-id -i ~/.ssh/ demoserver

The ‘demoserver’ name in this command will be found as the ‘Host’ in the ~/.ssh/config file.

You should be asked to enter the password of the ‘User’ you’re connecting as. If successful, you should be disconnected with a prompt to login by typing: “ssh demoserver”

Note: permission changes might be needed on these files

chmod 700 ~/.ssh
chmod 640 ~/.ssh/authorized_keys