Starting ssh-agent on KDE startup

Using keys for SSH authentication is a great way to login securely and save having to type passwords over and over again. However to keep your private key safe, you'll want it encrypted with a passphrase which means you'll have to type your (hopefully) complex passphrase every time you ssh to another box instead - not ideal.

ssh-agent is an authentication agent which can load your key into memory, and use it to authenticate as required. You generally run ssh-agent, then use ssh-add to add the key to the agent.

Here's a quick way to run ssh-agent when KDE starts, so that you can add your key with ssh-add (automate that too if you like), then it will be available throughout your KDE session.

KDE has many config dirs and files under ~kde/ but the two we're particularly interested in are ~/.kde/env/ and ~/.kde/shutdown/. The env dir is for scripts which set env vars on KDE startup, and the shutdown dir is for scripts which should run on KDE shutdown.

So, create the following files:

#!/usr/bin/bash
eval ssh-agent
#!/usr/bin/bash
ssh-agent -k

The above files will start the ssh-agent when KDE starts, and shut it down when it ends.

Then, once KDE is running you can either do ssh-add yourself once to load the key into the agent, or you can see the old instructions above to run ssh-agent automatically.

A nicer way than using cvsaskpass would be to call kdialog instead.

~~DISCUSSION~~

 
linux/sshagentkdestartup.txt · Last modified: 2010/02/26 10:45 (external edit)
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki