看看这个例子:
ssh.connect('127.0.0.1', username='jesse',
password='lol')
stdin, stdout, stderr = ssh.exec_command(
"sudo dmesg")
stdin.write('lol\n')
stdin.flush()
data = stdout.read.splitlines()
for line in data:
if line.split(':')[0] == 'AirPort':
print line
在此处找到具有更多说明的示例:http : //jessenoller.com/2009/02/05/ssh- programming-with-paramiko-completely- different/
希望能帮助到你!