Python Forum

Full Version: SSH to a device using paramiko fails
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!