Running a Bash script over ssh

后端 未结 5 1375
春和景丽
春和景丽 2020-11-28 07:05

I\'m trying to write a Bash script that will SSH into a machine and create a directory. The long-term goal is a bit more complicated, but for now I\'m starting simple. Howev

5条回答
  •  借酒劲吻你
    2020-11-28 07:39

    Your script is doing substitution on the local host before being sent over.

    Change your first line to:

    ssh -T tunneluser@111.222.333.444 <<'EOI'
    

    This will cause the raw script to get sent over and interpreted on your remote host.

    If you wanted a mix (so for example, if you wanted the date command executed on your local host, you should leave ssh line unchanged and quote the individual command):

    ssh -T tunneluser@111.222.333.444 <

提交回复
热议问题