【发布时间】:2021-03-23 21:00:03
【问题描述】:
因此,戴尔在他们的新 iDRAC 固件中更改了一些内容,他们在您登录后需要键盘交互式身份验证,而我无法再使用 Paramiko 登录。
有人在论坛里贴了一个代码sn-p来修补Paramiko client.py 我在connect函数中添加了以下内容
if password is not None:
try:
self._transport.auth_password(username, password)
return
self._log(DEBUG, "trying password")
allowed_types = self._transport.auth_password(username, password)
if not allowed_types:
return
except SSHException as e:
saved_exception = e
elif two_factor:
if 'keyboard-interactive' in allowed_types:
try:
self._log(DEBUG, "trying interactive")
self._transport.auth_interactive_dumb(username)
return
except SSHException as e:
saved_exception = e
但仍然出现同样的错误。这是我正在使用的 ssh 连接功能。
def connectSSH(my_file, user_name, password):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ip = str(my_file.split(',')[0]).strip()
try:
ssh.connect(ip, 22, user_name, password, look_for_keys=False)
return ssh
except:
with open(f'{ip}.txt', 'a') as f:
f.writelines(ip + '\t COULDN\'T CONNECT\n')
当我在空闲状态下运行它时,它会连接但显示正在等待身份验证
ssh.get_transport()
这是我得到的回溯
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
stdin, stdout, stderr = ssh.exec_command('racadm getsysinfo')
File "C:\Users\kevinc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\paramiko\client.py", line 508, in exec_command
chan = self._transport.open_session(timeout=timeout)
File "C:\Users\kevinc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\paramiko\transport.py", line 875, in open_session
return self.open_channel(
File "C:\Users\kevinc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\paramiko\transport.py", line 1006, in open_channel
raise e
File "C:\Users\kevinc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\paramiko\transport.py", line 2055, in run
ptype, m = self.packetizer.read_message()
File "C:\Users\kevinc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\paramiko\packet.py", line 459, in read_message
header = self.read_all(self.__block_size_in, check_rekey=True)
File "C:\Users\kevinc\AppData\Local\Programs\Python\Python38-32\lib\site-packages\paramiko\packet.py", line 303, in read_all
raise EOFError()
EOFError
任何帮助表示赞赏
谢谢
【问题讨论】: