我正在一个使用SSHLibrary的遗留Robotframework项目中工作。我们将SSH服务器上的身份验证从带有密码的用户名更改为公钥/私钥。
基于来自SSHLibrary的文档,我使用了以下关键字:
Login With Public Key root /home/test/.ssh/key这将失败,在SSH日志中,我看到以下内容:
DEB [20220315-11:05:32.160] thr=1 paramiko.transport: starting thread (client mode): 0xd9528410L
DEB [20220315-11:05:32.167] thr=1 paramiko.transport: Local version/idstring: SSH-2.0-paramiko_1.18.5
DEB [20220315-11:05:32.220] thr=1 paramiko.transport: Remote version/idstring: SSH-2.0-OpenSSH_7.8
INF [20220315-11:05:32.220] thr=1 paramiko.transport: Connected (version 2.0, client OpenSSH_7.8)
DEB [20220315-11:05:32.227] thr=1 paramiko.transport: kex algos:[u'curve25519-sha256', u'curve25519-sha256@libssh.org', u'ecdh-sha2-nistp256', u'ecdh-sha2-nistp384', u'ecdh-sha2-nistp521', u'diffie-hellman-group-exchange-sha256', u'diffie-hellman-group16-sha512', u'diffie-hellman-group18-sha512', u'diffie-hellman-group14-sha256', u'diffie-hellman-group14-sha1'] server key:[u'rsa-sha2-512', u'rsa-sha2-256', u'ssh-rsa', u'ecdsa-sha2-nistp256', u'ssh-ed25519'] client encrypt:[u'chacha20-poly1305@openssh.com', u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'aes128-gcm@openssh.com', u'aes256-gcm@openssh.com'] server encrypt:[u'chacha20-poly1305@openssh.com', u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'aes128-gcm@openssh.com', u'aes256-gcm@openssh.com'] client mac:[u'umac-64-etm@openssh.com', u'umac-128-etm@openssh.com', u'hmac-sha2-256-etm@openssh.com', u'hmac-sha2-512-etm@openssh.com', u'hmac-sha1-etm@openssh.com', u'umac-64@openssh.com', u'umac-128@openssh.com', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-sha1'] server mac:[u'umac-64-etm@openssh.com', u'umac-128-etm@openssh.com', u'hmac-sha2-256-etm@openssh.com', u'hmac-sha2-512-etm@openssh.com', u'hmac-sha1-etm@openssh.com', u'umac-64@openssh.com', u'umac-128@openssh.com', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-sha1'] client compress:[u'none'] server compress:[u'none'] client lang:[u''] server lang:[u''] kex follows?False
DEB [20220315-11:05:32.228] thr=1 paramiko.transport: Kex agreed: diffie-hellman-group14-sha1
DEB [20220315-11:05:32.229] thr=1 paramiko.transport: HostKey agreed: ssh-rsa
DEB [20220315-11:05:32.229] thr=1 paramiko.transport: Cipher agreed: aes128-ctr
DEB [20220315-11:05:32.229] thr=1 paramiko.transport: MAC agreed: hmac-sha2-256
DEB [20220315-11:05:32.229] thr=1 paramiko.transport: Compression agreed: none
DEB [20220315-11:05:32.516] thr=1 paramiko.transport: kex engine KexGroup14 specified hash_algo <built-in function openssl_sha1>
DEB [20220315-11:05:32.517] thr=1 paramiko.transport: Switch to new keys ...
DEB [20220315-11:05:32.519] thr=2 paramiko.transport: Adding ssh-rsa host key for 192.168.1.1: 6d16a4a7a06421c155735b4a89c7ba9c
DEB [20220315-11:05:32.530] thr=1 paramiko.transport: userauth is OK
DEB [20220315-11:05:32.550] thr=1 paramiko.transport: Authentication type (password) not permitted.
DEB [20220315-11:05:32.550] thr=1 paramiko.transport: Allowed methods: [u'publickey']
DEB [20220315-11:05:32.707] thr=2 paramiko.transport: [chan 0] Max packet in: 32768 bytes
WAR [20220315-11:05:32.708] thr=1 paramiko.transport: Oops, unhandled type 3在我看来,它似乎没有使用公钥身份验证,而是试图使用密码进行连接。
Robotframework = 2.8.7
Robotframework-SSHLibrary = 2.1.3
Paramiko = 1.18.5发布于 2022-08-01 22:32:02
您的Paramiko版本非常老,它不能处理新的OpenSSH格式密钥。您应该将其转换为经典的OpenSSH格式:ssh-keygen -p -m PEM -f /home/test/.ssh/key
有关更多详细信息,请参见此answer
https://stackoverflow.com/questions/71480441
复制相似问题