简体   繁体   English

我的脚本适用于一台电脑,但不适用于另一台电脑

[英]my Script works on one pc, but not on another pc

I am using paramiko to connect to my PDU for AC off on control.我正在使用 paramiko 连接到我的 PDU 以控制 AC 关闭。

I do not face the issue on my laptop and my host system.我的笔记本电脑和主机系统没有遇到这个问题。 The code works well on both.该代码在两者上都运行良好。

But when I copy my code to use on new host system, below error start appearing, I tried to test on other laptop also having the issue:-但是,当我复制代码以在新主机系统上使用时,开始出现以下错误,我尝试在其他笔记本电脑上进行测试,也有问题:-

I uses the same connection for the UUT, it connects with no issue, then later connect to PDU to AC OFF and On.我对 UUT 使用相同的连接,它连接没有问题,然后连接到 PDU 以关闭和打开 AC。 The error will happen.会发生错误。 Is this something to do with the new systems?这与新系统有关吗?

Code:代码:

#Connect to PDU to AC OFF & ON. ***PDU Outlet # to be hard coded here for now***
ssh.connect(PDUipaddr, port=PDUport, username=PDUusrname, password=PDUusrpass)
print('PDU Connection Successful')

Error from IDLE:来自 IDLE 的错误:

Exception (client): Invalid key (class: RSAKey, data type: rsa-sha2-256
Traceback (most recent call last):
  
File "C:\Python\lib\site-packages\paramiko\transport.py", line 2129, in run
    self.kex_engine.parse_next(ptype, m)
  
File "C:\Python\lib\site-packages\paramiko\kex_group1.py", line 75, in parse_next
    return self._parse_kexdh_reply(m)
  
File "C:\Python\lib\site-packages\paramiko\kex_group1.py", line 120, in _parse_kexdh_reply
    self.transport._verify_key(host_key, sig)
  
File "C:\Python\lib\site-packages\paramiko\transport.py", line 1937, in _verify_key
    key = self._key_info[self.host_key_type](Message(host_key))
  
File "C:\Python\lib\site-packages\paramiko\rsakey.py", line 71, in __init__
    self._check_type_and_load_cert(
  
File "C:\Python\lib\site-packages\paramiko\pkey.py", line 622, in _check_type_and_load_cert
    raise SSHException(err.format(self.__class__.__name__, type_))
paramiko.ssh_exception.SSHException: Invalid key (class: RSAKey, data type: rsa-sha2-256

Traceback (most recent call last):
  
File "C:\Users\EV_PG\Desktop\AMDXIO Script\Test.py", line 26, in <module>
    ssh.connect(PDUipaddr, port=PDUport, username=PDUusrname, password=PDUusrpass)
  
File "C:\Python\lib\site-packages\paramiko\client.py", line 406, in connect
    t.start_client(timeout=timeout)
  
File "C:\Python\lib\site-packages\paramiko\transport.py", line 698, in start_client
    raise e
  
File "C:\Python\lib\site-packages\paramiko\transport.py", line 2129, in run
    self.kex_engine.parse_next(ptype, m)
  
File "C:\Python\lib\site-packages\paramiko\kex_group1.py", line 75, in parse_next
    return self._parse_kexdh_reply(m)
  
File "C:\Python\lib\site-packages\paramiko\kex_group1.py", line 120, in _parse_kexdh_reply
    self.transport._verify_key(host_key, sig)
  
File "C:\Python\lib\site-packages\paramiko\transport.py", line 1937, in _verify_key
    key = self._key_info[self.host_key_type](Message(host_key))
  
File "C:\Python\lib\site-packages\paramiko\rsakey.py", line 71, in __init__
    self._check_type_and_load_cert(
  
File "C:\Python\lib\site-packages\paramiko\pkey.py", line 622, in _check_type_and_load_cert
    raise SSHException(err.format(self.__class__.__name__, type_))
paramiko.ssh_exception.SSHException: Invalid key (class: RSAKey, data type: rsa-sha2-256

Paramiko Logging Failed System:- Paramiko 记录失败的系统:-

DEBUG:paramiko.transport:starting thread (client mode): 0xf6286260
DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.9.1
DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-Mocana SSH
INFO:paramiko.transport:Connected (version 2.0, client Mocana)
DEBUG:paramiko.transport:=== Key exchange possibilities ===
DEBUG:paramiko.transport:kex algos: diffie-hellman-group14-sha1, diffie-hellman-group1-sha1
DEBUG:paramiko.transport:server key: rsa-sha2-256, ssh-rsa
DEBUG:paramiko.transport:client encrypt: aes128-ctr, aes128-cbc, rijndael128-cbc, aes256-ctr, aes256-cbc, rijndael256-cbc, aes192-ctr, aes192-cbc, rijndael192-cbc, 3des-cbc
DEBUG:paramiko.transport:server encrypt: aes128-ctr, aes128-cbc, rijndael128-cbc, aes256-ctr, aes256-cbc, rijndael256-cbc, aes192-ctr, aes192-cbc, rijndael192-cbc, 3des-cbc
DEBUG:paramiko.transport:client mac: hmac-sha2-256, hmac-sha1, hmac-sha1-96, hmac-md5, hmac-md5-96
DEBUG:paramiko.transport:server mac: hmac-sha2-256, hmac-sha1, hmac-sha1-96, hmac-md5, hmac-md5-96
DEBUG:paramiko.transport:client compress: none
DEBUG:paramiko.transport:server compress: none
DEBUG:paramiko.transport:client lang: <none>
DEBUG:paramiko.transport:server lang: <none>
DEBUG:paramiko.transport:kex follows: False
DEBUG:paramiko.transport:=== Key exchange agreements ===
DEBUG:paramiko.transport:Kex: diffie-hellman-group14-sha1
DEBUG:paramiko.transport:HostKey: rsa-sha2-256
DEBUG:paramiko.transport:Cipher: aes128-ctr
DEBUG:paramiko.transport:MAC: hmac-sha2-256
DEBUG:paramiko.transport:Compression: none
DEBUG:paramiko.transport:=== End of kex handshake ===
ERROR:paramiko.transport:Exception (client): Invalid key (class: RSAKey, data type: rsa-sha2-256
ERROR:paramiko.transport:Traceback (most recent call last):
ERROR:paramiko.transport:  File "C:\Python\lib\site-packages\paramiko\transport.py", line 2129, in run
ERROR:paramiko.transport:    self.kex_engine.parse_next(ptype, m)
ERROR:paramiko.transport:  File "C:\Python\lib\site-packages\paramiko\kex_group1.py", line 75, in parse_next
ERROR:paramiko.transport:    return self._parse_kexdh_reply(m)
ERROR:paramiko.transport:  File "C:\Python\lib\site-packages\paramiko\kex_group1.py", line 120, in _parse_kexdh_reply
ERROR:paramiko.transport:    self.transport._verify_key(host_key, sig)
ERROR:paramiko.transport:  File "C:\Python\lib\site-packages\paramiko\transport.py", line 1937, in _verify_key
ERROR:paramiko.transport:    key = self._key_info[self.host_key_type](Message(host_key))
ERROR:paramiko.transport:  File "C:\Python\lib\site-packages\paramiko\rsakey.py", line 71, in __init__
ERROR:paramiko.transport:    self._check_type_and_load_cert(
ERROR:paramiko.transport:  File "C:\Python\lib\site-packages\paramiko\pkey.py", line 622, in _check_type_and_load_cert
ERROR:paramiko.transport:    raise SSHException(err.format(self.__class__.__name__, type_))
ERROR:paramiko.transport:paramiko.ssh_exception.SSHException: Invalid key (class: RSAKey, data type: rsa-sha2-256
ERROR:paramiko.transport:
Traceback (most recent call last):
  File "C:\Users\EV_PG\Desktop\AMDXIO Script\Test.py", line 28, in <module>
    ssh.connect(PDUipaddr, port=PDUport, username=PDUusrname, password=PDUusrpass)
  File "C:\Python\lib\site-packages\paramiko\client.py", line 406, in connect
    t.start_client(timeout=timeout)
  File "C:\Python\lib\site-packages\paramiko\transport.py", line 698, in start_client
    raise e
  File "C:\Python\lib\site-packages\paramiko\transport.py", line 2129, in run
    self.kex_engine.parse_next(ptype, m)
  File "C:\Python\lib\site-packages\paramiko\kex_group1.py", line 75, in parse_next
    return self._parse_kexdh_reply(m)
  File "C:\Python\lib\site-packages\paramiko\kex_group1.py", line 120, in _parse_kexdh_reply
    self.transport._verify_key(host_key, sig)
  File "C:\Python\lib\site-packages\paramiko\transport.py", line 1937, in _verify_key
    key = self._key_info[self.host_key_type](Message(host_key))
  File "C:\Python\lib\site-packages\paramiko\rsakey.py", line 71, in __init__
    self._check_type_and_load_cert(
  File "C:\Python\lib\site-packages\paramiko\pkey.py", line 622, in _check_type_and_load_cert
    raise SSHException(err.format(self.__class__.__name__, type_))
paramiko.ssh_exception.SSHException: Invalid key (class: RSAKey, data type: rsa-sha2-256

Paramiko Logging Passing System:- Paramiko 测井传递系统:-

DEBUG:paramiko.transport:starting thread (client mode): 0x300e2020
DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.8.1
DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-Mocana SSH
INFO:paramiko.transport:Connected (version 2.0, client Mocana)
DEBUG:paramiko.transport:kex algos:['diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1'] server key:['rsa-sha2-256', 'ssh-rsa'] client encrypt:['aes128-ctr', 'aes128-cbc', 'rijndael128-cbc', 'aes256-ctr', 'aes256-cbc', 'rijndael256-cbc', 'aes192-ctr', 'aes192-cbc', 'rijndael192-cbc', '3des-cbc'] server encrypt:['aes128-ctr', 'aes128-cbc', 'rijndael128-cbc', 'aes256-ctr', 'aes256-cbc', 'rijndael256-cbc', 'aes192-ctr', 'aes192-cbc', 'rijndael192-cbc', '3des-cbc'] client mac:['hmac-sha2-256', 'hmac-sha1', 'hmac-sha1-96', 'hmac-md5', 'hmac-md5-96'] server mac:['hmac-sha2-256', 'hmac-sha1', 'hmac-sha1-96', 'hmac-md5', 'hmac-md5-96'] client compress:['none'] server compress:['none'] client lang:[''] server lang:[''] kex follows?False
DEBUG:paramiko.transport:Kex agreed: diffie-hellman-group14-sha1
DEBUG:paramiko.transport:HostKey agreed: ssh-rsa
DEBUG:paramiko.transport:Cipher agreed: aes128-ctr
DEBUG:paramiko.transport:MAC agreed: hmac-sha2-256
DEBUG:paramiko.transport:Compression agreed: none
DEBUG:paramiko.transport:kex engine KexGroup14 specified hash_algo <built-in function openssl_sha1>
DEBUG:paramiko.transport:Switch to new keys ...
DEBUG:paramiko.transport:Adding ssh-rsa host key for [10.47.7.42]:22: b'5289cb302fda3e4cfb5c6382c85916f9'
DEBUG:paramiko.transport:userauth is OK
INFO:paramiko.transport:Auth banner: b'+============================================================================+\r\n|                      EATON ePDU Configuration Utility                      |\r\n+============================================================================+\r\n'
INFO:paramiko.transport:Authentication (password) successful!
PDU Connection Successful
B2B & R2R Completed... Check Logfiles.
DEBUG:paramiko.transport:EOF in transport thread

You are using different versions of Paramiko on the two machines.您在两台机器上使用不同版本的 Paramiko。 The failing machine uses newer 2.9.1.故障机器使用较新的 2.9.1。 Paramiko 2.9 added support for rsa-sha2-256 keys . Paramiko 2.9 添加了对rsa-sha2-256 keys 的支持 Your server supports these too, so Paramiko and the server agree on using them.您的服务器也支持这些,因此 Paramiko 和服务器同意使用它们。 While the machine with older Paramiko 2.8.1 uses ssh-rsa keys.而具有较旧 Paramiko 2.8.1 的机器使用ssh-rsa密钥。

But something seems to go wrong with rsa-sha2-256 keys.但是 go 似乎与rsa-sha2-256键有问题。 I cannot tell whom to blame.我说不出该怪谁。 It can be a bug in new rsa-sha2-256 implementation in Paramiko.它可能是 Paramiko 中新rsa-sha2-256实现中的一个错误。 But it can also be a bug in the server, as you are using some minor (Mocana SSH) server, which might not be well tested.但这也可能是服务器中的错误,因为您使用的是一些小型(Mocana SSH)服务器,可能没有经过很好的测试。


In any case, you should be able to bypass the problem by avoiding use of the rsa-sha2-256 keys:无论如何,您应该能够通过避免使用rsa-sha2-256密钥来绕过该问题:

ssh.connect(PDUipaddr, port=PDUport, username=PDUusrname, password=PDUusrpass,
   disabled_algorithms=dict(pubkeys=["rsa-sha2-256"]))

Note that such code won't run on the machine with Paramiko 2.8.1, as the disabled_algorithms was added only in 2.9.请注意,此类代码不会在使用 Paramiko 2.8.1 的机器上运行,因为disabled_algorithms仅在 2.9 中添加。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 python 脚本在我的电脑上正常,但在另一台电脑上不行 - python script ok on my pc but not on another Python - socket.gethostbyaddr() 在一台 PC 上失败,但在另一台 PC 上工作 - Python - socket.gethostbyaddr() fails in one PC but works on another 将 Pywinauto 模块从一台 PC 复制到另一台 PC - Copy Pywinauto module from one PC to another 我的自定义宏可在我的PC上运行,但在目标计算机上崩溃 - My custom macro works on my pc but crashes on target computer ModuleNotFoundError:没有名为“?”的模块错误仅出现在一台 PC 上,而在另一台 PC 上,程序使用 Spyder 4 运行 - ModuleNotFoundError: No module named “?” Error appears just on one PC and on other PC the Program works using Spyder 4 Python Matplotlib特定图形生成可在一台PC上运行,但不能在其他PC上运行 - Python Matplotlib Specific Figure Generation Works on One PC but Not Other 执行使用未安装在另一台PC中的库的脚本,是否会安装它? - Executing a script that uses a library not installed in another pc, will install it? Python 错误,它是一个脚本并在我的主电脑上工作 - Python errors, its a script and working on my main pc 当我打开我的电脑时运行 python 脚本 - running a python script when i turn my pc on 使用RabbitMQ将消息从一台PC发送到另一台PC - Send a message from one PC to another using RabbitMQ
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM