You should generate the key pair on the computer that is used as client to connect to the SSH server.
In reality it doesn't matter where you generate the keys, but for practical use do it on the client.
The following instructions applies on the majority of unixes, OS X included. I won't cover Windows here.
Open Terminal. Copy and paste the line below. Hit return at the end
ssh-keygen -t dsa
Your output should look like this
Generating public/private dsa key pair.
Enter file in which to save the key (/Users/xxxx/.ssh/id_dsa):
Created directory '/Users/xxxx/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/xxxx/.ssh/id_dsa.
Your public key has been saved in /Users/xxxx/.ssh/id_dsa.pub.
The key fingerprint is:
f9:08:6b:01:b8:03:9a:5e:3d:ce:d8:93:17:56:b3:eb xxxx@iMac.local
The key's randomart image is:
+--[ DSA 1024]----+
| |
| . |
|. . . o |
|.o ... ..o |
|o o. oooS. |
|. ..= ++.o. |
| . . *o.... |
| .o . |
| E |
+-----------------+
What you get.
inside your home folder will be created a new hidden folder named .ssh
.ssh contains 2 files
- id_dsa (private key. Keep this file secure. Never give it to anyone)
- id_dsa.pub (public key. It is useless without the private key)
For security reason you should provide a password (passphrase) that locks the private key. If you do, don't foget it 😉
Last step, is to copy the public key,id_dsa.pub, on the server. You can use a USB stick to facilitate the task.
Once on the server drag and drop, from the USB stick, id_dsa.pub onto the Desktop.
Open Terminal. Copy and paste the following line
mkdir ~/.ssh;chmod 700 ~/.ssh;cat ~/Desktop/id_dsa.pub >> ~/.ssh/authorized.keys;chmod 600 ~/.ssh/authorized.keys
You probably get some errors if .ssh already exists on the SSH server. Do not care about that