Python Forum
SSH to a device using paramiko fails - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Networking (https://python-forum.io/forum-12.html)
+--- Thread: SSH to a device using paramiko fails (/thread-4316.html)



SSH to a device using paramiko fails - MikeHill - Aug-07-2017

Hi All Smile
My requirement is to simply ssh to a router using python paramiko

So I being new to python wrote this simple script but nothing happens when I run it.
But I CAN connect using this command in Ubuntu
admin1ubu@ubuntu01:~$ ssh -l user1 192.168.100.1
Password:

R1>


Here is the code that wrote

#!/usr/bin/env python
import paramiko
import time

session = paramiko.SSHClient()
session.set_missing_host_key_policy(paramiko.AutoAddPolicy())
session.connect("192.168.100.1",port=22, username = "user1",password = "pass1")
connection = session.invoke_shell()
connection.send("terminal length 0\n")
time.sleep(1)

connection.send("\n")
connection.send("configure terminal\n")
time.sleep(1)
Not even an error is given when I run this script
Please let me know what I am doing wrong
Thanks!