ClearChain

Setting up SSH Public/Private Keys

Using SSH for Automatic Key authentication

SSH provides an encrypted tunnel for use with interactive and non interactive terminal sessions. It provides authentication via a number of methods including password, public/private key pairs and challenge keys.

SSH also provides authentication forwarding between machines. This feature allows a user to be able to log on to a machine without the need of typing a password. This is an extreemly strong feature as it means you can provide access to an account or even to execute a command without the need to provide someone with a password.

In order to setup public/private key authentication forwarding both the client and the server must have knowledge of the relevant keys. You must also consider the version of SSH software that the server/client is running as different versions use different files. Generating SSH Keys

The first step is to generate an SSH private/public key pair. For this I assume you are using some version of OpenSSH. There is currently three types of ssh key pairs that can be generated. They are rsa1, rsa and dsa. Of these dsa is the most secure and is the one used by ssh2. To generate the key perform the following:

  ssh-keygen -t rsa1
  ssh-keygen -t rsa
  ssh-keygen -t dsa

The public/private keys will be installed in the following places

SSH Version Key Type OpenSSH SSH 2(Commercial)
old ssh1 rsa1 ~/.ssh/identity & ~/.ssh/identity.pub Not Generatable
ssh1 rsa2 ~/.ssh/id_rsa & ~/.ssh/id_rsa.pub ~/.ssh2/id_rsa_[keywidth]_a & /.ssh2/id_rsa_[keywidth]_a.pub
ssh2 dsa ~/.ssh/id_dsa & ~/.ssh/id_dsa.pub ~/.ssh2/id_dsa_[keywidth]_a &/.ssh2/id_dsa_[keywidth]_a.pub

Automated Authentication

With the keys generated it is now possible to setup automatic key authentication. This means when you log in to a machine you don’t need to enter your password. The authentication happens by the server encrypting some data with your public key then challenging the client to decript it. For this to happen, the client must have the private key matching the public key.

The procedure to set this up varies up which server you attempting to access. The procedure is basically as follows:

  scp [publickey] user@host:~
  ssh user@host
  cat [publickey] >> [filename]

The above is the basic procedure. However the publickey and filename vary depending on the server/client you are using. A valid example for OpenSSH using dsa keys is:

 

  scp ~/.ssh/id_dsa.pub user@host:~
  ssh user@host
  cat id_dsa.pub >> ~/.ssh/authorized_keys2

The table below shows which file to copy where:

Local OpenSSH Key OpenSSH (Remote Machine) SSH2(Commercial) (Remote Machine)
identity.pub Unknown At present Unknown at present
id_rsa.pub ~/.ssh/authorized_keys 1 ~/.ssh2/id_rsa_SECSH.pub & “echo key id_rsa_SECSH.pub >> authorization”
id_dsa.pub ~/.ssh/authorized_keys2 1 ~/.ssh2/id_dsa_SECSH.pub & “echo key id_dsa_SECSH.pub >> authorization”

Note 1: In order to generate an SECSH compliant key the following OpenSSH Command can be used:

  ssh-keygen -e -f [KEY].pub > [KEY]_SECSH.pub

Exit mobile version