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:
-
Install the ‘keychain’ package:
sudo yum install keychain
-
Start the ssh-agent:
eval $(keychain --eval --agents ssh id_rsa)
-
Add your ssh private key(s) to the ssh-agent:
ssh-add ~/.ssh/id_rsa
-
Update your shell profile script, e.g. ~/.bash_profile, to include the following line:
source ~/.keychain/$HOSTNAME-sh
-
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.