Using ssh with wallet on KDE

How can I use wallet with ssh keys?

I found many different descriptions, I've got ssh-agent running, I've added a script at Autostart/ssh-add.sh:

#!/bin/bash
export SSH_ASKPASS=/usr/bin/ksshaskpass
/usr/bin/ssh-add  ~/.ssh/id_rsa.2
/usr/bin/ssh-add  ~/.ssh/id_rsa.3

When KDE started for the first time after adding that, I was asked for a password to unlock wallet, and for the password for unlocking the files. I've checked, the passwords are stored in wallet.

However when I run ssh from command line, then I'm still asked for the password for ssh account.

Any ideas what I could check or change?


Solution 1:

This post suggests using kssaskpass: and it worked on my machine™ (Kubuntu 20.10)

  1. Install ksshaskpass (was already installed for me)

    sudo apt install ksshaskpass

  2. Create an autostart script (script content below)

    nano ~/.config/autostart-scripts/ksshaskpass.sh

  3. Add execute permissions and run the autostart script

    chmod +x ~/.config/autostart-scripts/ksshaskpass.sh

    ~/.config/autostart-scripts/ksshaskpass.sh

I was prompted for all of the SSH key passwords (ticking the 'Remember password for each), and with the KWallet Manager open I could see them being added to the wallet one by one.

Here's my version of ~/.config/autostart-scripts/ksshaskpass.sh:

#!/bin/bash
  
export SSH_ASKPASS='/usr/bin/ksshaskpass'

# loop through all RSA private keys (change this if you need to)
for i in ~/.ssh/*_rsa; do
        ssh-add $i < /dev/null
done