Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run telnet over ssh in python

       telnet
server ←————→ device
  ↑
  | SSH
  ↓
localhost (me)

I have a device that is connected with one server computer and I want to talk to the device by ssh'ing into the server computer and send telnet commands to my device. How do I setup things in Python to make this happen?

like image 763
Dhruv Patel Avatar asked Feb 01 '26 06:02

Dhruv Patel


1 Answers

You can use Python's paramiko package to launch a program on the server via ssh. That program would then in turn receive commands (perhaps via stdin) and return results (via stdout) from the controlling program. So basically you'll use paramiko.SSHClient to connect to the server and run a second Python program which itself uses e.g. telnetlib to talk to the device.

like image 80
John Zwinck Avatar answered Feb 02 '26 19:02

John Zwinck