What is the cleanest way to ssh and run multiple commands in Bash?

前端 未结 12 2246
礼貌的吻别
礼貌的吻别 2020-11-22 09:14

I already have an ssh agent set up, and I can run commands on an external server in Bash script doing stuff like:

ssh blah_server "ls; pwd;"
         


        
12条回答
  •  误落风尘
    2020-11-22 09:40

    Edit your script locally, then pipe it into ssh, e.g.

    cat commands-to-execute-remotely.sh | ssh blah_server
    

    where commands-to-execute-remotely.sh looks like your list above:

    ls some_folder
    ./someaction.sh
    pwd;
    

提交回复
热议问题