I\'m desinging test cases in which I use paramiko for SSH connections. Test cases usually contain paramiko.exec_command()
calls which I have a wrapper for (call
This works:
import paramiko
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # Setting the missing host policy to auto add it
client.connect('192.168.1.16', port=22, username='admin', password='admin', timeout=3, banner_timeout=2)
channel = client.invoke_shell() # Request an interactive shell session on this channel. If the server allows it, the channel will then be directly connected to the stdin, stdout, and stderr of the shell.
print channel.closed # False
command = 'reboot'
channel.send(command + '\n')
# wait a while
print channel.closed # True