Run Local Script On Remote System via SSH

Started by nikolaymartin, May 07, 2020, 07:40:24 AM

Previous topic - Next topic

nikolaymartin

I have a script in my system. I want to run this script on the remote system which has SSH connection.

deanwebb

https://zaiste.net/a_few_ways_to_execute_commands_remotely_using_ssh/ covers this answer:

"A local script can be executed against remote machine with a simple stdin redirection."

stdin is short for "standard input". I just learned that to-day. :smug:

You can also redirect output from the remote machine to your local machine with stdout redirection. This is good to know.

But now my interests turn to security matters as I await someone from the same IP to post a link to the PKK website that results in an error 404, since they really don't have many programming resources over there. It's mostly stuff that's banned completely by the Turkish government. And the fact that the IP address used for both the Q and the A are from Turkey makes the PKK reference all the more delicious, I would say. Play on, autobot espammers that joined a year ago and only now started real activity that smacks of human handoff to AI systems.
Take a baseball bat and trash all the routers, shout out "IT'S A NETWORK PROBLEM NOW, SUCKERS!" and then peel out of the parking lot in your Ferrari.
"The world could perish if people only worked on things that were easy to handle." -- Vladimir Savchenko
Вопросы есть? Вопросов нет! | BCEB: Belkin Certified Expert Baffler | "Plan B is Plan A with an element of panic." -- John Clarke
Accounting is architecture, remember that!
Air gaps are high-latency Internet connections.

Otanx

Are you saying these aren't honest questions? That somone who writes in PHP doesn't know how to restart services, or use cp? I am shocked.

Honestly I didn't know you could run stuff with SSH like that. Might be useful in the future. So thank you bot. I learned something today.

-Otanx

deanwebb

I postulate that the questions and answers are themselves honest, but the eventual posting of the link is what violates the policy 'round here, and, therefore, the forces behind such postings are themselves not on the honest side of the fence.

And yes, but it is wond'rous strange that a PHP coder would not know how to restart services, let alone express an opinion about init.d and why it would be favoured over other sundry methods.
Take a baseball bat and trash all the routers, shout out "IT'S A NETWORK PROBLEM NOW, SUCKERS!" and then peel out of the parking lot in your Ferrari.
"The world could perish if people only worked on things that were easy to handle." -- Vladimir Savchenko
Вопросы есть? Вопросов нет! | BCEB: Belkin Certified Expert Baffler | "Plan B is Plan A with an element of panic." -- John Clarke
Accounting is architecture, remember that!
Air gaps are high-latency Internet connections.

edizgeorgi

#4
It is very easy just put the script file path after the ssh command like below.
ssh ismail@192.168.142.144 'bash -s' < cat myscript.sh
Look: https://www.networking-forums.com/programming-goodies-and-software-defined-networking/run-local-script-on-remote-system-via-ssh

deanwebb

And that there is the syntax for a stdin redirection. :smug:

That the poster protesteth not the charges levied, ah! There's the proof for the charges themselves! That, or Google Translate fails on archaic forms of English language usage. I shall test, anon...

And the translation therein prov'ed beyond mortal comprehension. I have baffled, and therefore they are not Belkin employees!
Take a baseball bat and trash all the routers, shout out "IT'S A NETWORK PROBLEM NOW, SUCKERS!" and then peel out of the parking lot in your Ferrari.
"The world could perish if people only worked on things that were easy to handle." -- Vladimir Savchenko
Вопросы есть? Вопросов нет! | BCEB: Belkin Certified Expert Baffler | "Plan B is Plan A with an element of panic." -- John Clarke
Accounting is architecture, remember that!
Air gaps are high-latency Internet connections.