networking - Python SSH Connection with Paramiko & Netmiko libs -


if give help, have issue hop ssh conections. can´t use (netmiko ssh proxy support keith), maybe because i´m running in windows box.

so connect via ssh hop server , router using paramiko lib. next want pull netmiko send/retrive commands/outputs, allways receive errors connecthandler when start ssh connection paramiko:

error: line 40, in <module>     net_connect = connecthandler(device_type='cisco_ios', ip='x', username='x', password='x')   file "build\bdist.win-amd64\egg\netmiko\ssh_dispatcher.py", line 96, in connecthandler   file "build\bdist.win-amd64\egg\netmiko\base_connection.py", line 89, in __init__   file "build\bdist.win-amd64\egg\netmiko\base_connection.py", line 396, in establish_connection netmiko.ssh_exception.netmikotimeoutexception: connection device timed-out: cisco_ios x.x.x.x:22 

below (simple) code, fresh in programming, code can awful :(.

import paramiko import netmiko netmiko import connecthandler getpass import getpass import time import re import sys  # first ssh connection remote_conn_pre=paramiko.sshclient() remote_conn_pre.set_missing_host_key_policy(paramiko.autoaddpolicy()) remote_conn_pre.connect(ip, port=22, username=username,                           password=password,                         look_for_keys=false, allow_agent=false)  remote_conn = remote_conn_pre.invoke_shell() output = remote_conn.recv(65535) print output  # second ssh connection remote_conn.send("ssh x@ip x \n>") time.sleep(3) remote_conn.send("password\n") output1 = remote_conn.recv(65535) print output1 time.sleep(3)  # trying run netmiko... net_connect = connecthandler(device_type='cisco_ios', ip='x.x.x.x', username='user', password='password')  net_connect.find_prompt()  cisco_show_acl_x = net_connect.send_command("show run | s access-list x ") 


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -