Ssh套接字已关闭。想要一个交互式sshshellautomation for Linux的机器import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
##Creating Ssh Session
ssh.connect("gfr4123408", port=22, username='rstrusr',password='Password')
stdin,stdout,stderr = ssh.exec_command('symcfg -lockbox reset -ssv')
#Here it asks for password and i want to write password below
stdin.write("Password")
stdin.write('\n')
stdin.flush()
output=stdout.readlines()
print(output)
我得到以下错误
Traceback (most recent call last): File "", line 1, in
stdin.write('password') File "C:\Users\venkar2\AppData\Local\Programs\Python\Python36\lib\site-packages\paramiko\file.py",
line 402, in write
self._write_all(data) File "C:\Users\venkar2\AppData\Local\Programs\Python\Python36\lib\site-packages\paramiko\file.py",
line 519, in _write_all
count = self._write(data) File "C:\Users\venkar2\AppData\Local\Programs\Python\Python36\lib\site-packages\paramiko\channel.py",
line 1333, in _write
self.channel.sendall(data) File "C:\Users\venkar2\AppData\Local\Programs\Python\Python36\lib\site-packages\paramiko\channel.py",
line 831, in sendall
sent = self.send(s) File "C:\Users\venkar2\AppData\Local\Programs\Python\Python36\lib\site-packages\paramiko\channel.py",
line 785, in send
return self._send(s, m) File "C:\Users\venkar2\AppData\Local\Programs\Python\Python36\lib\site-packages\paramiko\channel.py",
line 1169, in _send
raise socket.error('Socket is closed') OSError: Socket is closed
我要为200多个设备配置,如何解决这个问题??在