Python Forum
Need Help in ssh connection
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need Help in ssh connection
#1
Hi All,

                ssh_client=paramiko.SSHClient()
                ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
                ssh_client.connect(hostname = ip, username= user, password = passwd, timeout = 100)
                stdin, stdout, stderr = ssh_client.exec_command("\npower outlets 17 off\n")


I used above lines of code for ssh connection and to execute required command.

This code is working if peer device is in "#" prompt but my device is in ">" prompt & I'm unable to execute command (able to login into device)

Thanks in advance
Reply
#2
i remember working with a power strip device that used ssh and had ">" prompts a few years ago when i was getting started with Python to automate several sysadmin things. i use the pexpect module to be triggered by the prompts and send commands. i got it working that way.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#3
See if there anything in this 'interactive mode' demo that will help: https://github.com/paramiko/paramiko/blo...ractive.py
Reply
#4
Thank you Both,
with Pexpect my problem was rectified.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020