...
ssh-keygen without parameters generates 2048 RSA public and private keys,
- Private key kept on the client machine = id_rsa
- Public key put on the target server machine = id_rsa.pub which will then be added into ~/.ssh/authorized_keys
Code Block | ||
---|---|---|
| ||
ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/Users/tinpham/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/tinpham/.ssh/id_rsa. Your public key has been saved in /Users/tinpham/.ssh/id_rsa.pub. The key fingerprint is: c7:6c:3e:87:4a:09:90:ef:6d:a9:88:f8:f0:89:d2:13 tinpham@Tin-Phams-iMac.local The key's randomart image is: +--[ RSA 2048]----+ | . oo. | | s .. . | | ...++ .| | T . +.=...| | F o + *. | | + o + . | | C . | | . + | | | +-----------------+ |
...
It accomplishes in one command,
(Roderick you should fill this in)
Manually Copy Over Public Key to the Target Server
Since I happen to be using Mac OS X I do this manually,
...
Code Block | ||
---|---|---|
| ||
cd ~/.ssh cat ~/id_rsa.pub >> authorized_keys # appends the contents of the your public key to the authorized_keys file cd ~ rm id_rsa.pub # no need to keep this file around |
Here is how everything should look in terms of permissions,
Code Block | ||
---|---|---|
| ||
ls -al
drwx------ 2 tin.pham staff 4096 Jan 23 19:35 .
drwxr-xr-x 5 tin.pham staff 4096 Jan 15 20:41 ..
-rw------- 1 tin.pham staff 410 Jan 15 20:41 authorized_keys
-rw------- 1 tin.pham staff 1671 Jan 23 19:35 id_rsa |
If you have been using SSH before, you might also see a file called known_hosts (will link and explain to this later).
Test Key Based Authentication
...