Wednesday, February 1, 2012

Loading Your SSH Key at Login

I have two Linux machines that I periodically use ssh and scp between. Tonight I finally got tired of having to repeatedly enter my key’s passphase. So I looked up how to ssh-add my key to ssh-agent when KDE starts. On Kubuntu, KDE automatically loads ssh-agent with the session, so you only have to do a couple things to get everything set up:
  1. Generate your keypair if you haven’t already done so.
  2. Install ksshaskpass (aptitude install ksshaskpass)
  3. Create file called askpass.sh in ~/.kde/Autostart and add the following:
    #!/bin/sh
    export SSH_ASKPASS=/usr/bin/ksshaskpass
    /usr/bin/ssh-add < /dev/null
    
  4. chmod 755 ~/.kde/Autostart/askpass.sh
  5. Logout and back in, again.
Ksshaskpass will ask you for your kwallet passphrase. It will then ask for your private key’s passphrase. At the bottom of the dialog it has a checkbox for it to remember your passphrase. Now when you log in (assuming you checked the box) you will only have to enter your wallet password. You can make your ssh key passphrase ridiculously complex this way because only kwallet needs to remember it. Now my machines trust each other and I can zip between them.

No comments:

Post a Comment