How to handle multiple ssh connections

wlanboy

Content Contributer
I am running three mail servers for different domains. Therefore I often check them at the same time.

It is a pain in my head to run the same commands on different terminal windows again and again.

So I searched for a tool that can handle this. And I found clusterssh.

Installation is easy:


sudo apt-get install clusterssh
or
sudo yum install clusterssh

Configuration can be done system wide (/etc/clusters) or per user (~/.csshrc). I prefer the second option.


nano ~/.csshrc
clusters = mail_servers mongodb_cluster ruby_workers
mail_servers =vps1 vps2 vps3
mongodb_cluster = vps4 vps5 vps6 vps7
ruby_workers = vps8 vps9

You can define "clusters" which simple are groups of hostnames

If you combine that with you ssh client config


nano ~/.ssh/config

Host vps1
HostName 192.1.1.1
Port 22
User myuser
IdentityFile ~/.ssh/id_myuser_vps1
[...]

You just have to type in:


cssh mail_servers

And clusterssh open 3 xterm windows and opens the connection to the three hosts.

An additional window will open too:

2coo868.jpg

Every command typed into this window will be forwarded to all ssh connections.

2r77uae.jpg

You can even deselect hosts or add new hosts or clusters on runtime.

Another shortcut is to just add the hosts as parameters:


cssh vps1 vps 5 vps7 vps8

Add "--help" to see all the options.

One of my fav time saver toos.
 

peterw

New Member
I tried to build a bash script for this problem, but this tool is great! Thank you for sharing this tool.
 

eva2000

Active Member
Nice.. i can also already do this within SecureCRT with similar function 'send chat to all sessions' allows me to enter command once and populates to all open tabbed sessions. Easily manage dozens of servers typing commands only once :)
 

Echelon

New Member
Verified Provider
I've always been a user of copy/paste if I'm jamming the same command down multiple ssh sessions at once. That being said, it's nice to know there's software out there for it to make life a little easier. Might have to bookmark this one. ;) Thanks.
 

peterw

New Member
Found PAC Manager. Looks good and works as it should. Developer description of pac manager:

PAC is a Perl/GTK replacement for SecureCRT/Putty/etc (linux ssh/telnet/... gui)... It provides a GUI to configure connections: users, passwords, EXPECT regular expressions, macros, etc. You like 'SecureCRT/SSHMenu'?
 
Top