Skip to content

Automatically unlock your SSH keys

If your SSH keys are encrypted, you can configure the system to unlock them automatically in each new terminal window and tab you open.

The way to do this depends on which shell you use:

zsh

(The default shell in KDE Linux; you’re using this one if you didn’t change anything.)

In your ~/.zshrc file, add the following on its own line anywhere:

ssh-add

bash

In your ~/.bashrc file, add the following lines anywhere:

export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
ssh-add

Do it the old-fashioned way

KDE Linux automatically sets up a single-instance SSH agent and populates the required SSH_AUTH_SOCK environment variable for instant use. Turning it off and setting things up manually is not recommended.

If you still want to, mask the relevant systemd service with systemctl mask --now --user ssh-agent.service, and then set things up to your taste.


Article contributed by under the CC-BY-4.0 license.