Using ssh-agent with KDE?

Solution 1:

My simple solution is to just run one ssh-agent and always keep it running. You can kill it on log-out if you really want to. The key is to just use a fixed socket. Add ssh-agent -a /tmp/$USER.agent to an Autostart script. Then do "export SSH_AUTH_SOCK=/tmp/$USER.agent" followed by ssh-add. Also, you can add that export to your .bashrc, .profile or other shell log-in script and always have access to the agent even when using a remote ssh in.

Solution 2:

This is an old question, and probably deserves an updated answer. The following works for me (Fedora 31 / KDE).

  1. Set up KWallet with the default wallet (kdewallet) and with the same password as your login password. Ensure it unlocks on login. Arch Wiki has some info on that; in my case I had to uncomment some lines in /etc/pam.d/sddm.
  2. Create your SSH key (ssh-keygen) with whatever password you like (since you're going to use a password manager, it doesn't need to be memorable).
  3. Ensure ssh-add and ksshaskpass are installed.
  4. Add an auto-start script like the following:
    $ cat $HOME/.config/autostart-scripts/ssh
    #!/bin/sh
    SSH_ASKPASS=/usr/bin/ksshaskpass ssh-add </dev/null
    
    Do chmod +x and run it once. Ksshaskpass should ask your SSH password. Tell it to remember the password (this uses KWallet). Run again and notice this time it doesn't ask.

That should be it.

Tags:

Ssh

Kde

Ssh Agent