0

I have a script on my local machine, script.sh. I want to run it on a remote server that is only accessible by multiple ssh.

script.sh:

ls
ls
ls

I tried:

user@localhost:~/$ ssh -At host1 ssh -At host2 "bash -s" -- < ./script.sh

but the output was split onto multiple lines:

user@host2:~/$ ls
examples.desktop
user@host2:~/$ ls
examples.desktop
user@host2:~/$ ls

I also would like this to execute without putting me in a terminal on the remote machine.

How can I get the script to execute as a single command?

0

I was able to fix this by removing the -t flag, so that ssh didn't put me in a terminal on the remote host.

user@localhost:~/$ ssh -A host1 ssh -A host2 "bash -s" -- < ./script.sh

Output:

examples.desktop
examples.desktop
examples.desktop
user@localhost:~/$

It also kept me on the local host rather than landing me in a terminal on the remote host.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.