Setting up ssh to allow passwordless access

Introduction

This page explains how to set up ssh so that you can connect from one machine to another without being prompted for a password.

Procedure

  1. On the source side (where you ssh from), check if you have an SSH keypair already by running:
    ls ~/.ssh/id_[rd]sa.pub

    If that lists one file then you have an SSH keypair already; if it lists no files then you do not have an SSH keypair already; if it lists two files then you have two keypairs and you should probably move one key pair into /var/tmp and later delete it.

  2. If you need to create an SSH keypair then, still on the source side, run:
    ssh-keygen

    This will ask some questions; just press ENTER three times to accept the default answers to each question.

  3. Still on the source side, you need to copy the public half of the SSH keypair into the destination side’s authorized_keys file. The easiest way to do this is to run:
    ssh-copy-id <name-of-remote-account>@<name-of-destination-machine>

    where <name-of-remote-account> and <name-of-destination-machine> are the names of account on the destination machine and the name of the destination machine, respectively.

  4. Now you should be able to log in to the destination system without being prompted, just by running:
    ssh <name-of-remote-account>@<name-of-destination-machine>

See also

  1. ssh-keygen(1)
  2. ssh-copy-id(1)
  3. IT support pages
  4. Computing