Code is Love

Gnome Terminal Profiles for Connecting to Different Hosts

by someguy on Jan.19, 2007, under Uncategorized

I was really surprised that I couldn’t find a how-to to configure Gnome’s Terminal program to have various profiles to connect to different hosts. For those familiar, I was looking for something PuTTY like, where when I launched the program, I would have a list of hosts to connect to, rather than just opening a local shell and running the same ssh commands to different hosts each time I need to login to a remote system. Yes, I have heard that PuTTY runs on linux, but I really wanted to use Gnome Terminal since I use it every day and want to use more standard tools in my daily Linux life.

What I did find, however, was the Gnome Terminal Launcher Applet. This is an applet that runs in your Gnome tray/panel with a drop down menu for each of your terminal profiles. Sweet! I ran into a problem though: if I just put “ssh ” in the profile, ssh wouldn’t use my keys already in memory thanks to keychain and the ssh agent, of course. So, here’s where my hack comes into play — and might save you the same minor hassle.

Create a shell script in your home directory called terminal-helper with the following contents:

#!/bin/sh
. .bash_profile
ssh $1

so I get the benefit of the keychain lines pre-existing in my .bash_profile when it is sourced, and it just connects to whatever host I pass to the script (thanks, Diego, for removing some obvious clunkiness from the original implementation). In my Gnome Terminal profiles, on the “Title and Command” tab, I specify “Run command as a login shell”, “Run a custom command instead of my shell”, and then specify the command:
/home/myuser/terminal-helper <yourusernamehere>@<yourhostnamehere>

Now I can connect to whatever host I have created a profile for just by clicking on a drop down menu. 10-15 keystrokes per host saved! Heh. Enjoy.

:, ,

Leave a Reply

You must be logged in to post a comment.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...