Showing posts with label ssh-agent. Show all posts
Showing posts with label ssh-agent. Show all posts

Thursday, April 26, 2007

Puffing with SSHKeychain

In one of my previous articles I showed how you could use ssh-agent to your advantage to maximize lackadaisicalness. I have since then moved from the Ubuntu laptop that I was using at the time to my Mac that became available again.

I was looking for a nice and neat way to integrate ssh-agent into the Mac environment but could not get my shell scripting approach to gel elegantly. While doing the obligatory search on the web I found and fell in love with SSHKeychain.

This little app does all the had work (running ssh-agent from the correct place and exporting your keys into memory with ssh-add) for you, and more ... It not only handles the ssh-agent side of things but also provide support for integrating with the Apple Keychain and forward local ports over a ssh connection to set up ssh tunnels.

Go see the full feature list for more info.

Installation
Here are the step from their site:
  • Download SSHKeychain.dmg and mount it.
  • Copy SSHKeychain (SSHKeychain.app) to your Applications folder.
  • Run SSHKeychain. This should open a dock item and a statusbar item.
  • Click either the Statusbar Item, the Dock Item, or Main Menu and open the Preferences.
  • Open the Environment tab.
  • Enable "Manage global environment variables". This will make SSHKeychain available for other applications.
  • Open the keys tab and see if any of your keys are missing (~/.ssh/id_dsa and ~/.ssh/identity are default).
  • Re-login to make the global variables work.
  • Start up SSHKeychain, and you're set.
I added SSHKeychain to my Login Items in the System Preferences panel to ensure the app was running after a restart or log out/in sequence.

Setup
If you followed the installation instructions above there should be nothing further to do (assuming you had some pre-created keys in the default place like I had).

Excellent!

When I now fire Terminal.app up and log into a box that has my public key on it no password is required and I am logged in without further ado.

Friday, April 20, 2007

ssh-agent for Developers

Have you ever wanted to automate the ssh pass phrase login procedure when connecting to remote systems that have your public key in their .ssh/authorized_keys?

This is done using ssh-agent (and ssh-add) which will be on your Debian or Ubuntu system if you have the openssh-client dep installed. For other flavours of Linux, OS X or UNIX please refer to your package management documentation (or install from source) to see how you can install the required software.

On an Ubuntu system ssh-agent is started for you by default. Please refer to your system documentation for ssh-agent to find the correct way to run it on your system.

The following approach should work for situations where the client (the computer with the private key) is either a server (access is generally restricted to it via remote shell) or a desktop (includes laptops) with a graphical terminal program.

Add the following to the end of your ~/.bashrc (or other suitable shell setup configuration file):
# Run ssh-add if it has not been run already.
if ssh-add -l | grep -q 'The agent has no identities.'
then
eval "ssh-add"
fi
Save the addition to your .bashrc (or suitable alternative) and log out and back in.

You will be presented with a request for your pass phrase you chose when creating your public/private keys. Enter it and sigh with relief as your default key(s) are cached in memory.

When you now try and log into the remote system again there will be no passwords or pass phrases required for this session.

About Me

My photo
I love solving real-world problems with code and systems (web apps, distributed systems and all the bits and pieces in-between).