Run command on multiple linux servers from windows

One of the major concern for sysadmin is to run same/repetitive command on multiple Linux servers in infra when there is no centralized tool available. In this post we are going to see how to run a command on multiple Linux servers in one go. There is no need of saving your account password anywhere and even no need to have expect function in your source machine!

Pre-requisite :

  • Windows machine with plink downloaded on it (download plink here)
  • Linux servers should be reachable from windows machine

Howto do it :

plink is a putty command line utility. Using plink we will be able to connect to server by supplying IP, username, password on command line. plink can be invoked from command prompt on windows.

Goto Windows command prompt by typing cmd in run window (windows key + r). Navigate to folder where plink executable is kept and then type in plink command as above.

ssh : protocol to connect

id@server ip

pw : account password

Commands to execute on Linux server in braces.

This is how plink works. Now to execute same command on multiple server we see below example. We will connect to 3 servers and execute hostname & date command.

First put all 3 server’s IP addresses in single file (ip_list.txt). Then execute simple for loop on that file as below in command prompt. This is very basic batch script.


Voila! all server’s command output is there! Commands executed on all servers in one go.

This is very useful when you need to check some single line outputs from all servers or if you want to run account refresh commands on all servers in one go.

Any thoughts?