Playing with org mode and ssh 

Problem

There are a lot of machines that I have ssh acces to; virtual machines (both in vmware and virtualbox), linodes (personal, work, projects), production systems, etc.. All told there are probably over 200 systems out there which I will need to ssh into at some point in the future. Sometimes I go years without logging in.

Some of these systems have domain names, but most are just random IPs over some vpn. I can never remember how to get in and have to spend time figuring out what box it is that I need to access

Failed Solutions
~/.ssh/config


Of course I have ssh keys setup and I use different key pairs for different roles and uses. This has created a rather complex ~/.ssh/config.

I have tried to keep a list of systems in the config with an alias:

Host abc123
HostName 127.0.0.1
Port 1234
User username


Substitute sane values and about 200 of these and you rapidly create a large unmanageable mess.

/etc/hosts

Try to manage a large /etc/hosts file and you see first hand why dns was invented.

I even tried using scripts to pull information from puppet sources, linode api’s and even systems posting back on my public IP.

Obviously it became a mess

emacs to the rescue.
One day after being particularly frustrated when I couldn’t get into a box, I was adding yet another entry to ~/.ssh/config only to realize it was in there twice already, I decided to turn this problem into a nail so I could use my universal hammer, emacs.

(defun jgk/xterm-ssh (host)
"Spawn a xterm with a ssh to the host"
(start-process-shell-command "*org-xterm-ssh*" "ssh-xterm" "xterm" "-e"
(concat "'ssh -AY " host "'")))

I now have an org file for each project I work on and can create links that will let me ssh into a system with a ‘click’


[[elisp:(jgk/xterm-ssh "username@192.168.15.218")][Magical Mystery Machine]]

Since it is in org mode I can now categorize and tag these links. I can take notes and use tramp to open directories.

I am slowly adding systems in as I need them. I have found the ability to keep notes and a basic log of what and why I was there to be invaluable.

If you need to access a lot of random systems you should try this, it has made my life sane
[ add comment ] ( 82 views ) permalink $star_image$star_image$star_image$star_image$star_image ( 3 / 69 )

| 1 |