Managing multiple SSH connections to various servers can be a challenging task, especially when dealing with a large number of servers. To streamline this process, a command-line utility called multi-ssh has been developed, leveraging tmux to facilitate simultaneous SSH connections. This tool offers a series of features that make it a powerful and flexible option for system administrators and developers alike.

Key Features of multi-ssh

multi-ssh is designed to optimize the experience of connecting to several SSH servers at once. It uses tmux, a terminal multiplexer that allows splitting a window into multiple panes, making it easier to view and manage several sessions simultaneously. Below are some of its key features:

  1. Flexible Layouts: Users can choose between a single window with multiple panes or separate windows for each server. This allows organizing the connections in the most convenient way according to personal preferences.
  2. Synchronized Input: It allows executing commands on all connected servers simultaneously, saving time by avoiding the need to execute the same command on each server individually.
  3. File Transfers: The tool facilitates file transfers between the local and remote servers using rsync, a very efficient utility for backups and file synchronization.
  4. Customizable Configurations: A simple configuration file allows users to easily manage server connections, set default commands for each server, and adjust other connection parameters.

Basic Usage

To start using multi-ssh, simply run the following command with a suitable configuration file:

./multi-ssh --config ~/servers.conf

This configuration file (in this case, servers.conf) may contain the servers to which you want to connect and their associated commands. You can customize options such as session names, SSH user, and commands to run on each server.

Available Options

The tool offers a variety of options for customizing the experience. Some of the most commonly used options include:

  • –layout <pane|window>: Defines the layout of the connections. You can choose a single window with multiple panes or separate windows for each server.
  • –synchronize-panes: Enables synchronized input across all panes, which is useful when executing the same command on multiple servers at once.
  • –session : Sets the session name both locally and remotely for better organization.
  • –remote-user: Allows switching users before creating the remote tmux session.

Example Usage

1. Connection with Pane Layout:

./multi-ssh --layout pane

This command will open a tmux session with multiple panes for each server.

2. Connection with Synchronized Panes:

./multi-ssh --synchronize-panes

This enables synchronized input across all connected servers, executing the same command on all of them at the same time.

3. Executing Remote Commands:

./multi-ssh exec 'uptime'

This command will execute the uptime command on all the connected servers.

4. File Transfer Using rsync:

./multi-ssh copy ./myfile.txt remote:~/myfile.txt

This command will transfer a file from the local machine to the remote servers.

Comparison with Similar Tools

Here is a comparison between multi-ssh and other popular tools for managing simultaneous SSH connections, such as pssh and clusterssh:

Featuresmulti-sshpssh (parallel-ssh)clusterssh (cssh)
Paradigmtmux-based session managerParallel command executorMulti-window manager
InterfaceSingle tmux sessionCommand-line (non-interactive)Multiple xterm windows
InteractionInteractive (within tmux)Non-interactiveInteractive (console sync)
Synchronizationtmux synchronize-panesN/A (Parallel execution)Master console input broadcast
LayoutPanes or windows (toggleable)N/ASeparate graphical windows
Remote SessionManages remote tmux sessionsNoNo
Built-in CopyYes (rsync)Yes (pscp/prsync)No (manual scp/rsync)
Built-in KillYes (Remote tmux kill)Yes (pnuke)No (manual kill)
ConfigurationConfig file + CLIHost file + CLIConfig file + CLI
Dependenciesbash, tmux, ssh, rsyncpython, sshperl, ssh, X11, xterm
Primary Use CaseInteractive tmux multi-adminBatch command executionInteractive multi-admin

Contributing

multi-ssh is an open-source project under the MIT license. Contributions, suggestions, and feature requests are welcome.

If you are a system administrator looking for a powerful solution to manage multiple SSH connections interactively and programmatically, multi-ssh offers a robust and flexible alternative to more limited solutions like pssh and clusterssh.

For more details, documentation, and the source code, visit the GitHub repository: multi-ssh on GitHub.

Conclusion

With multi-ssh, system administrators and developers can manage multiple servers simultaneously and efficiently, with the flexibility that tmux offers and a variety of advanced options. Whether executing commands in parallel, managing remote tmux sessions, or transferring files between machines, this tool provides an excellent alternative to other solutions like pssh and clusterssh.

Scroll to Top