Tricks in Linux
From Computational Biophysics and Materials Science Group
Passwordless SSH
Set Up:
- Run ssh-keygen -t dsa
- Choose a spot to save the file, default location is the best.
- Choose a password, or leave blank for no password
- Retype password, or leave blank.
Adding a Host:
- Start the agent and connect the termal with ssh-add as described below.
- Call ssh-copy-id <host name>
- Enter the password for that host
- Test it by calling ssh <host name>, if you log in with out being prompted by a password everything worked. Otherwise check the .ssh/autorized_keys file on the remote machine.
Use:
- Start the ssh key daemon by calling eval `ssh-agent` (I usually alias this step. alias ssh-ag='eval `ssh-agent`') Note the PID number of the agent printed in the terminal.
- In the termial or script you wish to have passwordless ssh type ssh-add. If you have a password you will be prompted for it once while you have the terminal open.
- Use ssh as normally. Adding -A will forward this keyless option with later ssh calls.
cd $HOME
ssh-keygen -t rsa1 -N "" -f $HOME/.ssh/identity
ssh-keygen -t rsa -N "" -f $HOME/.ssh/id_rsa
ssh-keygen -t dsa -N "" -f $HOME/.ssh/id_dsa
cd .ssh
touch authorized_keys authorized_keys2
cat identity.pub >> authorized_keys
cat id_rsa.pub id_dsa.pub >> authorized_keys2
chmod 640 authorized_keys authorized_keys2