A Priori

  • if you only have installed one protocol version of ssh on your system, the ssh command (and related commands) are not numbered; you have to use ssh instead of ssh1 and ssh2. You should consult your documentation to identify which version you have installed, or you can try `ssh -V' and see what version is reported.
  • Do read the section about Using SSH, because it contains some tips that can make life much nicer when using ssh ;-)

6 Steps to Setting up SSH

These 6 steps to use ssh assume you want to connect to a remote computer running Unix (called remote in the rest of this text) using ssh, from a client running Unix, Windows or MacOS (called client in the rest of this text), using a public and private key pair.

  1. Decide which protocol version you want to use:

    • You can choose between protocol version 1 and 2.
    • The protocol 2 offers more security, but you need of course both a protocol 2 capable client locally and likewise daemon on the remote computer to connect to. Most such daemons operate in a protocol 1 compatible mode, such that they can answer connections from both a protocol 1 and 2 client.
    • Most Unix computers in our department are equiped with a protocol 2 capable daemon (OpenSsh) and thus accept connections for both protocols.

    If possible, you should use protocol version 2, but do make sure you use the same protocol version on both client and remote !

  2. Create a public and private key pair:
    (normally, you create such a key pair on/for each client from which you want to connect from ... it is best created on the client itself ... and of course for each protocol you want to use)

      OpenSsh on Unix:
    • using protocol 1:
        execute ssh-keygen -t rsa1 and give a passphrase
    • using protocol 2:
        execute ssh-keygen -t dsa and give a passphrase
          when connecting to a regular Ssh2 server (i.e. not an OpenSsh server), you need to convert that key to a format understood by such a server:
        execute ssh-keygen -e -f ~/.ssh/id_dsa
    • Ssh1 on Unix :
      execute ssh-keygen1 and give a passphrase
      Ssh2 on Unix :
      execute ssh-keygen2 and give a passphrase
      ssh on Windows/MacOS :
      implementation dependent, consult the help with the program or use a key pair generated on Unix; in the latter case make sure you use the corresponding protocol on the Unix host to generate the key pair.

  3. Identify on (your account on) client which private key to use when connecting to remote:

      Ssh1 and OpenSsh on Unix :
      nothing needs to be done
        (by default Ssh1 and OpenSsh using protocol 1 use the private key in the file ~/.ssh/identity. OpenSsh using protocol 2 with dsa by default uses the private key in the file ~/.ssh/id_dsa. If you put your private key in a file with a different name, you need to specify it when using/calling ssh.)
      Ssh2 on Unix :
      put a line with `IdKey id_dsa_1024_a' in ~/.ssh2/identification on client
        (id_dsa_1024_a is the default, you could have specified a different name with the ssh-keygen command
        In this way you specify you want to use that identity when connecting. You can specify more (private) keys in that file, each will be tried in order, until one succeeds to connect. In this way, you can use several key pairs.
        )
      ssh on Windows/MacOS :
      implementation dependent, consult the help with the program. If you used a key pair generated on Unix, you already have configured the program to use a specific private and public key.

  4. Look for the public key of your (account on the) client:

      OpenSsh on Unix:
    • using protocol 1:
        ~/.ssh/identity.pub
    • using protocol 2, with an DSA key:
        ~/.ssh/id_dsa.pub
    • using protocol 2, with an RSA key:
        ~/.ssh/id_rsa.pub

        (these are the defaults, you could have specified a different name with the ssh-keygen command)
    • Ssh1 on Unix :
      ~/.ssh/identity.pub
        (this is the default, you could have specified a different name with the ssh-keygen command)
      Ssh2 on Unix :
      ~/.ssh2/id_dsa_1024_a.pub
        (this is the default, you could have specified a different name with the ssh-keygen command)
      ssh on Windows/MacOS :
      implementation dependent, consult the help with the program. If you used a key pair generated on Unix, you already have configured the program to use a specific private and public key.

  5. Authorize (your account on) remote to accept and use that key:

      OpenSsh on Unix :
    • using protocol 1:
        put the public key of your (account on) client in ~/.ssh/authorized_keys on remote
    • using protocol 2:
        put the public key of your (account on) client in ~/.ssh/authorized_keys2 on remote

        (these files thus contain all keys that are authorized to connect to the machine using that account, one on each line)

      The ssh-keygen command can transform from and to other formats of keys to be able to connect to/from Ssh2 servers/clients. Consult the man page for a description of the -e and -i options.
    • Ssh1 on Unix :
      put the public key of your (account on) client in ~/.ssh/authorized_keys on remote
        (this file thus contains all keys that are authorized to connect to the machine using that account, one on each line)
      Ssh2 on Unix :
      put the public key of your (account on) client in ~/.ssh2/a_name.pub on remote
        (it is of course best to use a meaningfull name for the file containing the public key e.g. the name of the (account on the) client in question)
      put a line with `Key a_name.pub' in ~/.ssh2/authorization
        (this file corresponds to the authorized_keys file for Ssh1, but it contains a reference to the files containing the public keys, instead of the public keys themselves)
      ssh on Windows/MacOS :
      we assume you only want to connect to a machine running Unix.
      we know of no reliable public domain version of an ssh daemon for Windows/MacOS. If you know of such a public domain daemon, please notify us.

  6. Login to remote from client using ssh:

      OpenSsh on Unix :
      ssh remote
        You can use the options -1 and -2 to specify the exact protocol to use.
      Ssh1 on Unix :
      ssh1 remote
      Ssh2 on Unix :
      ssh2 remote
      ssh on Windows/MacOS :
      implementation dependent; usually you must pop up a window where you fill in the name of the remote host you want to connect to (remote) and the account you want to login with.