1

I would like to send SSH commands to Unifi antennas, specifically the following command: set-inform http://unifi.<ip>:<port>/inform. This command is fully functional with Putty but when I use the following code, I get this response:

Resp: 
Err: ash: set-inform: not found

I suspect an error with the selected shell.

import paramiko

ip = 'XX.XX.XX.XX'
port = 22
username = 'XXX'
password = 'XXX'
try:
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(ip, port, username, password)

    stdin, stdout, stderr = ssh.exec_command("set-inform http://unifi.<ip>:<port>/inform")
    outlines = stdout.readlines()
    errors = stderr.readlines()
    resp = ''.join(outlines)
    respErrors = ''.join(errors)
    print('Resp: '+resp)
    print('Err: '+respErrors)# Output
except AttributeError:
    print("Erreur inconnue" + stderr)
except TimeoutError:
    print("Erreur de connexion")

1 Answers1

1

I need to specify the path to the command. Here is what to write:

stdin, stdout, stderr = ssh.exec_command(" /usr/bin/mca-cli-op set-inform http://unifi.<ip>:<port>/inform")

You can see the entire project here: https://github.com/simbarras/unifiAdopter

  • 1
    Cool, well done. Thank you for sharing back with the Stack Overflow community. You can accept your own answer and grab the points. – Mark Setchell Aug 10 '20 at 09:28