How can I automate running commands remotely over SSH to multiple servers in parallel?

前端 未结 20 1774
温柔的废话
温柔的废话 2020-12-12 20:03

I\'ve searched around a bit for similar questions, but other than running one command or perhaps a few command with items such as:

ssh user@host -t sudo su -         


        
20条回答
  •  孤街浪徒
    2020-12-12 20:36

    You can run a local script as shown by che and Yang, and/or you can use a Here document:

    ssh root@server /bin/sh <<\EOF  
    wget http://server/warfile    # Could use NFS here  
    cp app.war /location  
    command 1  
    command 2  
    /etc/init.d/httpd restart  
    EOF 
    

提交回复
热议问题