ssh on multiple servers at the same time

Prashanth

I have to login into various servers using ssh parallely using a shell script. It is a password less authentication. I have to login into 25 servers and restart a process which takes a lot of time. Hence i want to do the process in all the servers at the same time. My script goes like this:

while read line
do
ssh $line
------restart process-------
done < list.txt &

Here "list.txt" has the list of servers. I have used "&" to invoke new shell for each iteration and repeat the process for all servers. But the script is still executing the restart process for the servers in the list one after other. Its not executing the restart process at the same time. the server where script runs is bulit on bash whereas the 25 servers where the process has to be restarted are bulit on korn shell. Can anyone tell me what is the mistake in the script or parallel login using ssh is possible or not? Thanks in advance

Mark Setchell

Untested, but this should work using a heredoc - see Wikipedia heredoc:

while read line
do
   ssh $line <<'EOF' &
      command
      command
   EOF
done < list.txt

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

bash script to ssh multiple servers in a Loop and issue commands

From Dev

How to connect to multiple servers to run the same query?

From Dev

Running the same command on several ssh servers using tmux

From Dev

Jenkins CI - Run SSH Deployment on Multiple servers

From Dev

How to use camel JPA component on the same database with multiple servers?

From Dev

Multiple cronjobs at the same time

From Dev

Run multiple servers in python at same time (Threading)

From Dev

Run multiple commands in different SSH servers in parallel using Python Paramiko

From Dev

Using while loop to ssh to multiple servers

From Dev

Multiple commands, but not at the same time

From Dev

how to use ssh command to connect to multiple computers and send different commands to each computers at same time

From Dev

Run the same script on several servers through SSH

From Dev

Multiple docker servers using same containers

From Dev

Ssh into multiple servers and merge files into one

From Dev

Connect to multiple servers at the same time using sockets in NSStream

From Dev

Running sequential commands through ssh on multiple servers

From Dev

Does rsync establish a new ssh connection every time for multiple files or does it use the same connection?

From Dev

How to setup transparent ssh when there are multiple servers

From Dev

Passwordless ssh does not work with multiple servers

From Dev

Deploy multiple Content Delivery Servers with same confguration

From Dev

Multiple ssh servers in the same machine and proxy to redirect depends of the domain

From Dev

Multiple name servers on the same server

From Dev

SSH to multiple servers [Access denied]

From Dev

Connect to two OpenVPN servers at the same time

From Dev

tmux - split panes and ssh to multiple servers via script

From Dev

How to use reverse ssh tunneling with multiple jump servers

From Dev

Bash script to SSH to multiple servers and continue if login failed

From Dev

Deploy code on multiple servers from same branch

From Dev

how to run my selenium script on multiple servers at the same time so that i would saved one by one execution time?

Related Related

  1. 1

    bash script to ssh multiple servers in a Loop and issue commands

  2. 2

    How to connect to multiple servers to run the same query?

  3. 3

    Running the same command on several ssh servers using tmux

  4. 4

    Jenkins CI - Run SSH Deployment on Multiple servers

  5. 5

    How to use camel JPA component on the same database with multiple servers?

  6. 6

    Multiple cronjobs at the same time

  7. 7

    Run multiple servers in python at same time (Threading)

  8. 8

    Run multiple commands in different SSH servers in parallel using Python Paramiko

  9. 9

    Using while loop to ssh to multiple servers

  10. 10

    Multiple commands, but not at the same time

  11. 11

    how to use ssh command to connect to multiple computers and send different commands to each computers at same time

  12. 12

    Run the same script on several servers through SSH

  13. 13

    Multiple docker servers using same containers

  14. 14

    Ssh into multiple servers and merge files into one

  15. 15

    Connect to multiple servers at the same time using sockets in NSStream

  16. 16

    Running sequential commands through ssh on multiple servers

  17. 17

    Does rsync establish a new ssh connection every time for multiple files or does it use the same connection?

  18. 18

    How to setup transparent ssh when there are multiple servers

  19. 19

    Passwordless ssh does not work with multiple servers

  20. 20

    Deploy multiple Content Delivery Servers with same confguration

  21. 21

    Multiple ssh servers in the same machine and proxy to redirect depends of the domain

  22. 22

    Multiple name servers on the same server

  23. 23

    SSH to multiple servers [Access denied]

  24. 24

    Connect to two OpenVPN servers at the same time

  25. 25

    tmux - split panes and ssh to multiple servers via script

  26. 26

    How to use reverse ssh tunneling with multiple jump servers

  27. 27

    Bash script to SSH to multiple servers and continue if login failed

  28. 28

    Deploy code on multiple servers from same branch

  29. 29

    how to run my selenium script on multiple servers at the same time so that i would saved one by one execution time?

HotTag

Archive