June 18, 2008

Starting SSH connections simply with SSHMenu

Author: Ben Martin

SSHMenu adds a button to your GNOME panel that displays a configurable drop-down list of hosts that you have might like to connect to with SSH.

SSHMenu is packaged and available in repositories for both Ubuntu (as sshmenu-gnome) and Fedora (gnome-applet-sshmenu). Other SSHMenu packages available for both distributions do not include GNOME support. In those, the button for the SSH menu is started in its own window and an xterm is started when you wish to connect to a host with SSH. If you install the GNOME-aware SSHMenu packages, you can add SSHMenu to your panel by right-clicking the panel and choosing "Add to Panel..." and selecting the "SSH Menu Applet." When using the GNOME-aware SSHMenu, a gnome-terminal is started to handle your SSH connections, and you can select the profile gnome-terminal should use on a per-host basis. That lets you specify a font and background color in the terminal that can act as a reminder of which host that terminal is connected with.

Life without SSHMenu

If you are using GNOME, you can mimic much of the functionality of SSHMenu using the Application Launcher panel applet to show a personal menu of SSH connection options. For example, you can run alacarte to edit your GNOME menus, creating a new menu for SSH connections and new menu items in that menu for each SSH connection that you wish to start. You can then add the menu itself to the panel to get SSHMenu type functionality (your SSH connections all in a menu with possible submenus) and also add individual SSH hosts that you connect with often directly to the panel itself for single-click access.

Using gnome-terminal profiles in the above setup lets you specify different font and color parameters for each SSH connection. Your launchers execute something like:

gnome-terminal --window-with-profile=me@overthere.example.com

where the gnome-terminal profile me@overthere.example.com uses the custom command ssh me@overthere.example.com to automatically connect terminals created in that profile to the remote host.

The maintenance headache of having explicit profiles for each user and host combination grows rapidly. If you are running a collection of virtual machines for testing purposes, having a single gnome-terminal profile and using SSHMenu to connect as specific users and hosts might be a quicker option.

Life with SSHMenu


With SSHMenu, you don't have to set up individual gnome-terminal profiles for each host. You can still use profiles to set different font and color characteristics for connections, but you can group many connections to use the same gnome-terminal profile -- for example, a single profile that sets a unique background color and font slightly larger to remind you that you are the root user on a given connection.

There's a downside of not having a specific gnome-terminal profile for each SSH connection. When using SSHMenu to start your connections, you will find that when you hit Control-Shift-T to get a new tab, you will not be connected to the remote host with SSH in the new tab. If the gnome-terminal had an explicit profile, with the custom command for the profile set to SSH into the remote host, then any new terminal tab or window created with that profile would automatically be connected to the expected host with SSH.

How much this affects your usage depends on how often you use Control-Shift-T to get a new tab, or right-click a gnome-terminal window and select Open Terminal. If you start new terminals in either of these ways with any regularity, you might get a little frustrated by the new terminal having the same background color but not being connected to the expected host.

The preferences window of SSHMenu is split into Hosts and Options. The options tab allows you to enable tear-off menus, or open all the connections in a given submenu in windows or as tabs in the same new window.

The hosts tab lets you configure your SSH connections and arrange them into submenus, with the possibility of adding separators between menu items. For each SSH connection you add to your SSHMenu, you can configure the name given to it in the menu, what the window geometry will be for the terminal window started for that connection, what gnome-terminal profile to use for the connection, and the hostname to connect to. The hostname can include user@host and any options to the ssh command that you wish to pass in for the connection.

A great way to set the window geometry is to click the test button to spawn a gnome-terminal connected to the host, resize and relocate the gnome-terminal to where you want, then click the grab button in the SSHMenu Host Connection Details window and click on the gnome-terminal. If you have a submenu with a related collection of SSH hosts, and have set up the window geometry to place each of the gnome-terminal windows for the connections in that submenu in non-overlapping places on your screen, then SSHMenu's "Open All Windows" option for the submenu is very useful.

SSHMenu is written in the Ruby language and includes good support for adding extensions by specifying your own custom subclasses. A walkthrough is provided for adding telnet support, which could be used to add custom sftp client support and other communication protocols. The SSHMenu Hacker's Guide includes various hacks that can be used to customize SSHMenu, leading up to full-scale embedding of an SSHMenu in another application.

Wrap up

I tend to create new terminals from existing ones using Control-Shift-T often enough to get annoyed when I find that the new tab is not automatically connected through SSH to the same host as the original one was. However, SSHMenu makes up for that by letting you set up collections of SSH connections and, with a single click, open groups of related connections in either a collection of new windows or in a collection of new tabs in a single new window.


  • Tools & Utilities
  • Networking
  • Desktop Software
Click Here!