0
I would like to run a script located on my development machine on machine B that is only accessible via machine A.
So, my development machine --(SSH)--> machineA --(SSH)--> machineB
How do I do that? The script also takes arguments.
0
I would like to run a script located on my development machine on machine B that is only accessible via machine A.
So, my development machine --(SSH)--> machineA --(SSH)--> machineB
How do I do that? The script also takes arguments.
0
What you want is a tunnel via a jump host or proxy. There are several ways of doing this based on what exactly you are trying to do, but I believe putting something like this in ~/.ssh/config locally should work for your case:
Host b
ProxyJump a
Tested with this configuration:
Host localhost
ProxyJump 127.0.0.1
And it works like this (trimmed to show just the hops):
$ ssh -v localhost 'ls ~'
Authenticated to 127.0.0.1 ([127.0.0.1]:22).
Authenticated to localhost (via proxy).
[ls output]
I think that would probably work if you explain your answer a bit more. I am not very familiar with sshd config...so I do not know where each one of these configs go. – hebbo – 2018-04-27T20:46:25.083
1Is this clearer? – l0b0 – 2018-04-27T20:48:26.380
Is this clearer? – zee – 2018-04-28T02:51:13.170
-1
Let's say, you have the below script in the remote dev-machine.
remote-machine-x$ cat /home/userA/dev/zeebash
#!/bin/bash
echo "$@" | mail -s subject mygmailaccount@gmail.com
To execute this script from local machine, given that you have already set-up ssh-key, you can do it with something like this:
p="hi man" ; ssh userA@remote-machine-x "/home/userA/dev/zeebash "$p" "
I do not think you understood the question. – hebbo – 2018-04-27T20:44:40.983
The question is "Run a script on another machine accessible through another machine over ssh". If you mean something else, please explain. – zee – 2018-04-28T02:50:37.817
@zee OP is talking about three machines - local, A (the proxy host) and B (the server). They want to SSH via A to B and then run a script on B in one command. My solution does that. – l0b0 – 2018-04-29T05:35:27.323
Hi hebbo. I hope my close vote didn't make you delete the other question, that was not my intention. I marked this as a duplicate since this is basically a subset of the original question (how to run commands via a jump host), but I was in the process of writing an answer for it since there was an interesting quote-related issue in there as well. I'll just leave this link here in case you want to keep the question deleted but still want to learn about quoting.
– l0b0 – 2018-04-27T20:44:54.963