SSH II - Setup
Summary:- Generating Your Own Key Pair
- Distributing Your Key
- Keeping Keys In System Memory
Generating Your Own Key Pair
Generating and distributing your own keys has two advantages: you protect yourself from 'man-in-the-middle' attacks (e.g. by a machine which fakes the fingerprint of the remote host) and you can use one password for all the servers you connect to. Notice that there are currently two major, partly incompatible versions of SSH in use: version 1 and version 2. Whereas SSH version 2 servers can be configured to accept keys created with version 1, you are better off when you create two key pairs: one for version 1 and one for version 2. Since the names of the generated keys are different, they can be stored in the same directory and you can let the SSH server figure out which key it wants. The version 1 key is generated by the commandssh-keygen
ssh-keygen -t rsa
Generating RSA keys: ............................ooooooO......ooooooO<br> Key generation complete.<br> Enter file in which to save the key (/home/{user}/.ssh/identity):
{Just hit ENTER here unless you already have another key with that name, e.g. for a different SSH version}
Created directory '/home/{user}/.ssh'.<br> Enter passphrase (empty for no passphrase):{The entered passphrase will not appear on the screen.}
Enter same passphrase again:<br>
Your identification has been saved in /home/{user}/.ssh/identity.
{This is your private key.}
Your public key has been saved in /home/{user}/.ssh/identity.pub.<br> The key fingerprint is: 2a:dc:71:2f:27:84:a2:e4:a1:1e:a9:63:e2:fa:a5:89 {user}@{local machine}ssh-keygen -t rsa
ls -l ~~/.ssh/identity
ls -l ~~/.ssh/id_rsa
-rw––-
Distributing Your Key
On each server you need an SSH connection to, create a .ssh subdirectory in your home directory. Into this directory, copy the local file '/.ssh/identity.pub' and rename it to 'authorized_keys'. Likewise for version 2 keys: copy '/.ssh/id_rsa.pub' and rename it to 'authorized_keys2'. Now execute on the remote serverchmod 644 .ssh/authorized_keys .ssh/authorized_keys2
Simply put: it's better not to use key-based authentication on untrustworthy machines ;). section index
Keeping Keys In System Memory
This method comes in handy when you usually connect to more than one machine during a session. The trick is to run applications which are automatically authenticated. This is achieved by a combination of the programsssh-add
ssh-agent
man ssh-add
ssh-agent
eval
eval $(ssh-agent)
Agent pid {number}
ssh-add
ssh-add .ssh/id_rsa
ssh-add .ssh/identity .ssh/id_rsa
eval $(ssh-agent)
ssh-add
- which lists the key(s) currently kept in memory, and
ssh-add -l
- which removes an identity from the system memory.
ssh-add -d
Related Resources:
SSH FAQGetting started with SSH
man ssh-keygen
man ssh-add
man ssh-agent
Author: Tom Berger Legal: This page is covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB and Mandrakesoft.
SSH II - Setup
Version 1.5 last modified by Diwann on 09/09/2005 at 15:39
Version 1.5 last modified by Diwann on 09/09/2005 at 15:39
Document data
- Lost account?
- Join the community, be part of the Club: it's free!
- Get the PWP Download Subscription!



