Using SSH without Entering Your Password

Needs proofreading

$Revision: 148 $

$Date: 2007-01-09 18:56:30 +0100 (Di, 09 Jan 2007) $

You have two connected computers and want to log in to one computer from the other without entering your password every time.

Requirements

Check the following entries:

  1. Two computers, equipped with working network cards and properly connected.

  2. The package openssh is installed on both computers.

  3. The SSH port on both computers is open. You have to check your firewall settings.

  4. The SSH daemon runs on each computer.

Procedure

We assume that there are two computers with the following parameters:

 NameIP Address
Computer Aearth192.178.1.1
Computer Bmoon192.178.1.2

Do the following:

  1. Create your public and private key pair on earth first:

    1. Create the key pair with

      ssh-keygen -t rsa
    2. Enter the file in which to save the key. In general, you can use the default value and just hit Enter.

    3. Do not enter a passphrase.

  2. If you have the same login name on both computers, copy your public key to moon with:

    ssh-copy-id -i ~/.ssh/id_rsa.pub moon

    If you need to work on moon with a different user, use this:

    ssh-copy-id -i ~/.ssh/id_rsa.pub user_on_moon@moon

    If you do not have ssh-copy-id, use the following procedure:

    1. Export your public key to moon:

      cat ~/.ssh/id_rsa.pub | ssh moon 'cat >> .ssh/authorized_keys'
    2. Enter the password on moon.

    3. Log in to moon and set the correct permissions:

      chmod 644 ~/.ssh/authorized_keys
  3. Log in to moon with ssh moon. If need a different user, use ssh user_on_moon@moon.

After these steps, you can log in from earth to moon without entering a password. If you also want to log in the other way around, just exchange the two names and repeat the above steps.

Troubleshooting

If something does not work, check the following:

  1. Are the two computers connected properly?

  2. Can you ping earth from moon and vice versa? Use ping earth or ping 192.178.1.1.

For More Information

http://www.openssh.org/

This is the main Web page for SSH.

man ssh

Find more information about the command ssh in this man page.