LinuxCommandLibrary

mssh

Execute commands on multiple SSH servers simultaneously

TLDR

Open a new window and connect to multiple SSH servers

$ mssh [user@host1 user@host2 ...]
copy

Open a new window and connect to a group of servers predefined in ~/.mssh_clusters
$ mssh [[-a|--alias]] [alias_name]
copy

SYNOPSIS

mssh [-u username] [-p password] [-f hostfile]

PARAMETERS

-u username
    Specifies the username to use for SSH authentication on the remote hosts.

-p password
    Specifies the password to use for SSH authentication. WARNING: Use with caution as providing passwords on the command line can be a security risk.

-f hostfile
    Specifies a file containing a list of hostnames, one hostname per line.

command
    The command to be executed on each remote host.

DESCRIPTION

mssh is a utility designed to execute commands across multiple hosts using SSH. It reads a list of hostnames from a file or standard input, establishes SSH connections to each host, and executes the specified command. mssh simplifies the process of managing and administering multiple servers concurrently, allowing for tasks like software updates, configuration changes, or log file analysis to be performed across an entire infrastructure with a single command. It provides basic parallel execution capabilities, making it faster than sequentially SSHing into each machine. The command provides the username, password and command to run on each host.
The command is part of the clustershell package. It depends on having ssh access to all target machines.

CAVEATS

mssh requires that the user has SSH access to all target machines. Using password authentication can be insecure and should be avoided in favor of SSH keys where possible. The tool depends on the cluster shell package which might not be installed by default on all distributions.

SECURITY CONSIDERATIONS

When using mssh, always prioritize secure authentication methods like SSH keys. Avoid storing passwords in scripts or passing them directly on the command line. Ensure the hostfile is properly secured to prevent unauthorized access to the list of target machines.

HISTORY

mssh is part of the ClusterShell suite, developed to facilitate parallel command execution on clusters and large server farms. Its development was driven by the need for system administrators to efficiently manage and maintain a large number of machines simultaneously. The first commit dates back to 2006. It became a handy and lightweight tool to run one command on a number of servers.

SEE ALSO

ssh(1), scp(1), clustershell(1)

Copied to clipboard