How To Implement Keychain πŸ”

The Problem

If you are sick of re-entering your SSH passphrase per login shell πŸ˜’…

eval $(ssh-agent -s )
ssh-add ~/.ssh/id_rsa
# re-enter passphrase
SSH-Agent:

Keychain will allow you to enter your SSH passphrase per system reboot, 😲

How???

Keychain will automatically re-use your pre-existing ssh-agent process and have instant access to any pre-loaded keys and passphrases.

Keychain:

Summary of Steps

Below are the exact steps I took in the Keychain playlist.

You may have to adjust a few parameters to your environment but the Linux commands should be the same.

# Generate your SSH keypair (Public/Private)
# Public Key ends with a *.pub
# Private Key has no extension
ssh-keygen

# Copy Public Key to host(s)
ssh-copy-id -i /home/user1/.ssh/id_rsas.pub user1@remote1

# Test Private Key
ssh -i /home/user1/.ssh/id_rsa user1@remote1

#############################
#
# Legacy Method: NO KEYCHAIN 
#
#############################
eval $(ssh-agent -s )
ssh-add /home/user1/.ssh/id_rsa
# View loaded keys
ssh-add -l
# Test "agent process"
ssh -i /home/user1/.ssh/id_rsa user1@remote1

#############################
#
# NEW Method: KEYCHAIN! πŸ™‚
#
#############################
# Install keychain
sudo apt-get install keychain

#####################
# UPDATE: 01/12/2026
# Add the following to "~/.bashrc" and keychain will look
# for and use your pre-existing ssh-agent every time.
#####################
eval `keychain --eval --agents ssh /home/user1/.ssh/id_rsa`

# Test keychain
ssh user1@remote1


Keychain Concepts

Here I explain the concepts that make up ssh key authentication and keychain:


Demonstration

Here, I show you how to actually implement keychain:

Leave a comment