Error Remote Mikrotik Through Python Script

One of nice feature of Mikrotik is can be remoted through many ways one of them is by ssh, so i can create a python script using Paramiko as ssh client module but something strange when i want to create connection to mikrotik but it always fail although add parameters such as username, password and port are correct, in the mikrotik log shown this error message


[admin@Mikrotik] /log print

12:41:24 ssh,error expected: 50 got: 5
12:42:38 ssh,error expected: 50 got: 5

When i do some searching in google i found a solution in stackoverflow by adding argument  look_for_keys  with value False, here an example code that work for me

import paramiko

target = '192.168.56.88'

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(target, username='pigeon', password='kacangitem', look_for_keys=False)

stdin,stdout,stderr = ssh.exec_command('/log print')
print stdout.read()

7 thoughts on “Error Remote Mikrotik Through Python Script

Leave a comment