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 /home/user1/.ssh/id_rsa

# View loaded keys
ssh-add -l

# Test "agent process"
ssh -i /home/user1/.ssh/id_rsa user1@remote1
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 steps I took in the Keychain playlist.

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

Generate Key Pair

# 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

Keychain

# Install keychain
sudo apt-get install keychain

# Add the following to your  "~/.bashrc" 
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