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:
Helpful Resources
- https://wiki.archlinux.org/index.php/KDE_Wallet
- https://github.com/jlesquembre/blog/blob/master/posts/using-the-kde-wallet-to-store-ssh-keys-with-passphrases.rst
- Information on where to place the autostart script: https://askubuntu.com/questions/971105/what-is-the-difference-between-config-autostart-and-config-autostart-scrip