Weekly Journal 97 - Zsh ssh-agent Plugin
ssh-agent Plugin
I stumbled over this nifty [0][ssh-agent plugin] while looking for a way to automatically load a few SSH keys into ssh-agent
when I open a new WSL session in my terminal. [1][Oh My Zsh] ships with a large collection of plugins for enhancing your shell. This particular plugin allows you to automatically load SSH keys in to the agent whenever you start a new shell as well as configure other SSH options.
To use the plugin, you’ll need to make a few edits to your .zshrc
.
First, you’ll need to add it to the list of plugins to load:
1 | plugins=( |
Next, you’ll need to configure the options you want to use. In my case, I enable agent forwarding and provide a list of keys to load by default:
1 | # Enable ssh-agent forwarding |
You can use normal zsh features, so if you keep all your keys in a single directory, you can use the curly braces to list them all and save yourself some typing and make it easier to read your configuration.
Make sure you place these configuration lines before you source the Oh My ZSh script. In other words, make sure these statements appear before the line:
1 | source $ZSH/oh-my-zsh.sh |
This is a handy way to ensure my most-used SSH keys are loaded and ready when I need them.