How to install keychain manager for ssh-agent on CentOS 6/7

Keychain is a shell script that allows you to manage multiple ssh-agents and store the ssh keys for a user in one place. Here is how you can install and use Keychain on CentOS 6/7:

  1. Install the ‘keychain’ package:

     
    sudo yum install keychain
  2. Start the ssh-agent:

     
    eval $(keychain --eval --agents ssh id_rsa)
  3. Add your ssh private key(s) to the ssh-agent:

     
    ssh-add ~/.ssh/id_rsa
  4. Update your shell profile script, e.g. ~/.bash_profile, to include the following line:

     
    source ~/.keychain/$HOSTNAME-sh
  5. Log out and log back in to reload your shell profile script.

Now, every time you log in to your CentOS system, the ssh-agent and your ssh keys will be automatically loaded for you by Keychain. This allows you to use ssh and scp without having to enter your passphrase multiple times.

Leave a Comment