0

I have a problem with paramiko ssh on python. Whatever I do I receive only [] from any device I try to connect to (ubiquity, cisco, etc...) I've scouted the internet and I don't see what I'm doing wrong, could anyone help me ?

import paramiko

def SSH_CONN(IP,USERNAME,PASSWORD,COMMANDS):
    device = paramiko.SSHClient()
    device.load_system_host_keys()
    device.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    device.connect(IP, username=USERNAME, password=PASSWORD, port=22)
    stdin, stdout, stderr = device.exec_command(COMMANDS)
    device_return = stdout.readlines()
    print(device_return)
    device.close()

SSH_CONN("IP", "username", "password", "command")
Lowrider
  • 31
  • 1
  • 5
  • This doesn't help me because even if I read stderr it gives me [], same as from stdout. – Lowrider Dec 23 '20 at 08:49
  • The cannel method actually works for some reason (even though every single tutorial shows to use exec_command and not invoke_shell) but it gives me some wierd behavior when I send command it strips the first letter from it to a single line and the rest is on the second line do you have any idea why ? channel.send('enable') (SW1) > e nable – Lowrider Dec 23 '20 at 09:36

0 Answers0