SSH protocol provides different ways for authentication. Key based authentication is the most secure one. In order to use key based authentication we should store the key in a command place. SSH agents reads keys and uses for authentication with remote system. We can use
ssh-add to store keys in a common path.
Public and private keys are store in files according to their algorithm.
~/.ssh/identityholds RSA version 1 identity
~/.ssh/id_dsaholds DSA version 2 identity
~/.ssh/id_rsaholds RSA version 2 identity
If identity keys are readable by others they can not used by ssh-add.
Start Ssh Agent
ssh-agent is used to read keys for authentication.
ssh-agent works as daemon. We can simply start it like below.
$ eval `ssh-agent`
Add Ssh Key
We will add ssh keys with the
ssh-add . We will provide the key we want to add. If the key is protected with encryption we need to provide the password. In this example we will add key named
mykey . This key is located in the current working directory but we can also provide absolute path of the key.
$ ssh-add mykey
List Ssh Keys
We can list added ssh keys with the
-L option like below. This will also print the type of the key with the name at the end of the line.
$ ssh-add -L