Python Forum
is it possible to run commands on a device which is two servers away from our PC in P - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: is it possible to run commands on a device which is two servers away from our PC in P (/thread-11060.html)



is it possible to run commands on a device which is two servers away from our PC in P - Nirosh123 - Jun-20-2018

Hello Guys

I want to run python script in PC to connect to a router which can be accessed via 2 jump server, and the command out put should come my PC ,below is the scenario.if it possible how to do it in Python.

PC-----> Server1------------>Server2-------->Router

Thanks in Advance


RE: is it possible to run commands on a device which is two servers away from our PC in P - nilamo - Jun-20-2018

SSH? Or, if all the machines are behind your firewall, telnet?

How would you do it without python?


RE: is it possible to run commands on a device which is two servers away from our PC in P - wavic - Jun-20-2018

Welcome!

Just login to the desired server and run the command. If you can't reach it I doubt that you could manage the router ;) If I am net admin I won't allow such a thing.


RE: is it possible to run commands on a device which is two servers away from our PC in P - gontajones - Jun-20-2018

You'll have to port forwarding the data stream:

PC_IP:3000  <-> 3000:SERVER_1_IP:3001 <-> 3001:SERVER_2_IP:3000 <-> 3000:ROUTER_IP
With port forwarding every data that arrives at port 3000 (just for example) will be forward to the port 3001 (example)


RE: is it possible to run commands on a device which is two servers away from our PC in P - Nirosh123 - Jun-21-2018

(Jun-20-2018, 05:25 PM)Nirosh123 Wrote: Hello Guys I want to run python script in PC to connect to a router which can be accessed via 2 jump server, and the command out put should come my PC ,below is the scenario.if it possible how to do it in Python. PC-----> Server1------------>Server2-------->Router Thanks in Advance

(Jun-20-2018, 05:39 PM)nilamo Wrote: SSH? Or, if all the machines are behind your firewall, telnet? How would you do it without python?

Thanks for your reply,
On servers I do it using SSH and on Routers few with SSH and few with Telnet

(Jun-20-2018, 05:41 PM)gontajones Wrote: You'll have to port forwarding the data stream:
PC_IP:3000 <-> 3000:SERVER_1_IP:3001 <-> 3001:SERVER_2_IP:3000 <-> 3000:ROUTER_IP
With port forwarding every data that arrives at port 3000 (just for example) will be forward to the port 3001 (example)

Thanks friend for your reply, do your have any good document to refer


RE: is it possible to run commands on a device which is two servers away from our PC in P - gontajones - Jun-21-2018

(Jun-21-2018, 11:05 AM)Nirosh123 Wrote: Thanks friend for your reply, do your have any good document to refer

Search for port forwarding for the OS of both servers and for the specific router model.
It is not a big deal. If the servers are running Linux, you can do it using "iptables".

Let us know about your progress.


RE: is it possible to run commands on a device which is two servers away from our PC in P - Nirosh123 - Jun-21-2018

(Jun-21-2018, 11:32 AM)gontajones Wrote:
(Jun-21-2018, 11:05 AM)Nirosh123 Wrote: Thanks friend for your reply, do your have any good document to refer
Search for port forwarding for the OS of both servers and for the specific router model. It is not a big deal. If the servers are running Linux, you can do it using "iptables". Let us know about your progress.

Thank You, I will update you on thos


RE: is it possible to run commands on a device which is two servers away from our PC in P - nilamo - Jun-21-2018

(Jun-21-2018, 11:05 AM)Nirosh123 Wrote:
(Jun-20-2018, 05:25 PM)Nirosh123 Wrote: Hello Guys I want to run python script in PC to connect to a router which can be accessed via 2 jump server, and the command out put should come my PC ,below is the scenario.if it possible how to do it in Python. PC-----> Server1------------>Server2-------->Router Thanks in Advance

(Jun-20-2018, 05:39 PM)nilamo Wrote: SSH? Or, if all the machines are behind your firewall, telnet? How would you do it without python?

Thanks for your reply,
On servers I do it using SSH and on Routers few with SSH and few with Telnet

Ok, then do it with python using ssh or telnet. The approach using python won't be any different from what you already do, you'll just be automating it.