Tricks in Linux

From Computational Biophysics and Materials Science Group
Jump to: navigation, search

Passwordless SSH

Set Up:

  1. Run ssh-keygen -t dsa
  2. Choose a spot to save the file, default location is the best.
  3. Choose a password, or leave blank for no password
  4. Retype password, or leave blank.

Adding a Host:

  1. Start the agent and connect the termal with ssh-add as described below.
  2. Call ssh-copy-id <host name>
  3. Enter the password for that host
  4. 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:

  1. 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.
  2. 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.
  3. 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