Load SSH keys via Kwallet

Automatically add SSH keys after log in

This quick tip was tested on openSUSE Tumbleweed. However, it will probably work for other Linux distributions running KDE Plasma.

Install ksshaskpass5 via Zypper.

sudo zypper in --details ksshaskpass5

Create the script that will run ssh-add.

vim ~/bin/startup-scripts/ssh-add.sh

Add all the needed keys using ssh-add -q. The “q” here stands for quiet.

1
2
#!/bin/sh
ssh-add -q $HOME/.ssh/key1 $HOME/.ssh/key2 < /dev/null

Give execution permission to the script.

chmod +x ~/bin/startup-scripts/ssh-add.sh

Create the .desktop file that will be automatically parsed at KDE Plasma start-up.

vim .config/autostart/ssh-add.desktop

1
2
3
4
5
6
[Desktop Entry]
Exec=/home/your_user_name/bin/startup-scripts/ssh-add.sh
Icon=dialog-scripts
Name=ssh-add.sh
Type=Application
X-KDE-AutostartScript=true

Create another script in ~/.config/plasma-workspace/env/ to set the environment variable SSH_ASKPASS to use ksshaskpass.

vim ~/.config/plasma-workspace/env/ksshaskpass.sh

1
2
#!/bin/sh
export SSH_ASKPASS='/usr/libexec/ssh/ksshaskpass'

In the next login, a dialogue window asking for your SSH key password will appear for each added key. Ensure to mark the option “Remember password”. ksshaskpass

updatedupdated03-07-202203-07-2022
Load Comments?