Pages

Saturday 4 December 2021

Ssh-agent

 Recently, I had a situation where I was sharing same bastion hosts with other devs for connecting to our development K8s clusters. And due to some constraints all devs where using same user in that linux bastion vm. So here each devs was provided with each id_rsa private keys to use with tools like GIT.

And I used ssh-agent to select the key.

To start ssh agent:

eval `ssh-agent`

ssh-add <path-to-key>

Type in the password for the key. And now on GIT wont ask password for this key, in this session.

ssh-add -l # list all keys.We can add multiple keys.


usage: ssh-add [options] [file ...]
Options:
  -l          List fingerprints of all identities.
  -E hash     Specify hash algorithm used for fingerprints.
  -L          List public key parameters of all identities.
  -k          Load only keys and not certificates.
  -c          Require confirmation to sign using identities
  -t life     Set lifetime (in seconds) when adding identities.
  -d          Delete identity.
  -D          Delete all identities.
  -x          Lock agent.
  -X          Unlock agent.
  -s pkcs11   Add keys from PKCS#11 provider.
  -e pkcs11   Remove keys provided by PKCS#11 provider.