Borax Mans Pad
  • About
  • Blog
  • Articles
  • Levels
  • My Computing Setup
  • Programs
  • Links

SSH Server list menu for FVWM

This post describes how to create a convenience menu for FVWM which lists servers you can SSH into.

If you need to Secure Shell into a number of different machines, it may be useful to have a menu which lists those servers, and spawns a SSH client when connected. The session is started using ‘screen’ so it can be detached and resumed later.

There are a few components to this. First, we need a shell script to create the menu. This script will be read by FVWM’s ‘piperead’ when creating the menu.

The script is as below. Note that this script is configured to use xterm as the terminal emulator, change it as you see fit, and add an icon after ${DESCRIPTION}. $PROFILEDIR is where the SSH server profiles will be stored, again, you can change this, but I would recommend leaving it as is. Save this script as sshpipe.sh.

#!/bin/sh

HOST=""
USERNAME=""
PORT=""
DESCRIPTION=""
PROFILEDIR=${HOME}"/.ssh/profiles/"

echo "DestroyMenu recreate SSH"
echo "AddToMenu SSH \"SSH to server\" Title top"

for x in $(ls -BA ${PROFILEDIR}) ; do

	FILE=${PROFILEDIR}${x}

	exec 5<${FILE}
	read -r HOST <&5
	read -r USERNAME <&5
	read -r PORT <&5
	read -r DESCRIPTION <&5
	echo  + \"${DESCRIPTION}\" Exec exec xterm -e screen -S \"${DESCRIPTION}\"  -t \"SSH ${DESCRIPTION}\" ssh -l $USERNAME -p $PORT $HOST
	exec 5<&-

done

The next thing we need, is to get FVWM to run this scrup and read in the menu. Add this line to your FVWM config (I put it in the ‘menus’ config file) and change /path/to to wherever you saved sshpipe.sh, don’t forget to make sshpipe.sh executable.

PipeRead '/path/to/sshpipe.sh'

When FVWM runs the above line, it will create a menu called SSH.

Now we can just create a menu entry to an existing menu. I have this in my main menu.

+ "SSH to Server"	Popup SSH

Now we have FVWM reading the entries in ~/.ssh/profiles and creating menu entries based off of them. To add a server, simply create a file in ~/ssh/profiles. The name of the file doesn’t matter too much. These profiles do not store the password, but your using an SSH key instead, right?

The profile is a four line plain text file.

host to connect to
username
port
description

A made up example is below.

publicunix.net.au
boraxman
22
Australian Public Unix

Back to Home


© Dennis Katsonis 2025

GitGud