Setup KDE Wallet for Use with SSH Keys

Install ksshaskpass

Ksshaskpass is a front-end for ssh-add which stores the password of the ssh key in KWallet.

Find details of the project here: https://github.com/KDE/ksshaskpass.

It was already installed in my case on Kubuntu 18.10, but otherwise install from your package manager or preferred source.

user ~ $ sudo apt install ksshaskpass
ksshaskpass is already the newest version (4:5.12.6-0ubuntu0.1).

Create Autostart Script

Again from the ksshaskpass README:

make sure to set the SSH_ASKPASS environment variable to the path of ksshaskpass and then call ssh-add from your autostart scripts.

Based on a bit of reading, it appears that .config/autostart-scripts/ is a reasonable place to install the following script:

#!/bin/sh

SSH_ASKPASS='/usr/bin/ksshaskpass'
export SSH_ASKPASS

ssh-add < /dev/null

If you have additional keys (other than the default id_rsa, etc.), specify them by updating the last line of the script like so:

ssh-add ~/.ssh/id_rsa ~/.ssh/key2 < /dev/null

Save the script, make it executable, and run it for the first time:

$ chmod +x ssh-add-ksshaskpass.sh
$ ./ssh-add-ksshaskpass.sh 
Identity added: /home/user/.ssh/id_rsa (user@host)

If all went well (and one or more of your keys requires a passphrase) you should be met with the following dialog:

Ksshaskpass password dialog

Helpful Resources

Tags

 KDE Wallet  KDE  SSH Keys  ssh-agent  ksshaskpass  Kubuntu