Version 2 (modified by 12 years ago) ( diff ) | ,
---|
Passwordless SSH
Passwordless SSH is useful when you want to copy (scp
) a large number of files from one system to another, e.g. when moving files from the compute cluster's scratch space to a local machine.
In particular, if you find that your scp
jobs frequently stall, you can utilize a script to account for this when passwordless SSH is enabled.
Setting up passwordless SSH requires the generation and copying of a machine-specific key from the place where you're copying files from (the client) to the place you're copying files to (the server). This key must then be appended to a file on the server. This is accomplished as follows:
- On the computer you'll be copying files from (the client), go to
~/.ssh
and type the following. Follow all default prompts.ssh-keygen -t dsa
This will generate two files, by default calledid_dsa
andid_dsa.pub
. - Change the permissions of the generated .pub file to 600 be read/writeable only by you and not readable by anoyone else, with
chmod 600 id_dsa.pub
- Copy this file to the server, giving it a specific name in the process. For example, if your username is sunTzu, the client name is yin, and the target is yang, do
scp id_dsa.pub sunTzu@yang.machine:~/.ssh/yin.pub
- SSH to the server, and
cd ~/.ssh
- Append (or create) the file with this public key with
cat yin.pub >> authorized_keys
- You should now be able to SSH from the client to the server without typing your password.
To enable passwordless SSH in the other direction, perform the analogous actions. As a precaution, you should probably delete the yin.pub
file on the server.