linux关闭交互模式,Ssh套接字已关闭。想要一个交互式sshshellautomation for Linux的机器...

在尝试使用Paramiko库进行Linux设备的SSH自动化配置时,遇到了'Socket已关闭'的错误。该错误发生在尝试通过stdin写入密码到远程命令时。博主正在尝试对200多个设备执行'symcfg-lockboxreset-ssv'命令并输入密码。目前的代码导致了OSError,阻碍了自动化流程。寻找解决方案以实现批量设备的无阻塞配置。
摘要由CSDN通过智能技术生成

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多个设备配置,如何解决这个问题??在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值