• Uncategorized

About python : Making-SSH-from-a-jumpserverlinux-to-Devicesmodem-using-Python

Question Detail

I’m trying to execute few commands in a Jump server(linux) to access certain devices(modems) using SSH. And then get some device details after login in to the device(modem)
I’m using Paramiko to access jump server, the below code

import paramiko
import time
ssh = paramiko.SSHClient()

ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh.connect('jump server ip', username='user', password='pass', key_filename='D:\New folder\id_rsa')

stdin, stdout, stderr = ssh.exec_command('pwd') #prints the correct pwd

This works fine
So from the jump server I need to ssh a device(modem) using its ipv6 mac address.
the command is

sudo stbsshv6 'ipv6address'/n

But when I execute any command after ssh the device(modem), I’m not getting anything in stdout. Example:

import paramiko
import time
ssh = paramiko.SSHClient()

ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh.connect('jump server ip', username='user', password='pass', key_filename='D:\New folder\id_rsa')

stdin, stdout, stderr = ssh.exec_command('sudo stbsshv6 "ipv6address"')
stdin.write('ifconfig wlan0\n')#some working command
print stdout.readlines() # prints nothing

I can do manually the above steps using putty,

I’m new to python, can anyone suggest the right solution for this or any alternate way is also great. Thanks

Question Answer

No answer for now.

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.