通过Paramiko的SFTPClient进行的无密码连接无法正常工作

时间:2019-03-31 15:11:50

标签: python paramiko ssh2-sftp

我有两个lxd容器,一个master,另一个是slave。我已将ssh-key的{​​{1}}粘贴到master的{​​{1}}中,以便可以从~/.ssh/authorized_keys到{{1} },只需

slave

没有任何密码。

现在,我想使用master的{​​{1}}将文件从slave发送到ssh <slave-user>@<slave-ip> 。的代码将是:

master

我正在slave节点上运行此代码,而paramikoSFTPClient的IP地址。请注意,我可以使用>>> import paramiko >>> transport = paramiko.Transport(("10.154.151.252")) >>> transport.connect(username="root") /usr/local/lib/python3.5/dist-packages/paramiko/kex_ecdh_nist.py:39: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding. m.add_string(self.Q_C.public_numbers().encode_point()) /usr/local/lib/python3.5/dist-packages/paramiko/kex_ecdh_nist.py:96: CryptographyDeprecationWarning: Support for unsafe construction of public numbers from encoded data will be removed in a future version. Please use EllipticCurvePublicKey.from_encoded_point self.curve, Q_S_bytes /usr/local/lib/python3.5/dist-packages/paramiko/kex_ecdh_nist.py:111: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding. hm.add_string(self.Q_C.public_numbers().encode_point()) >>> sftp = paramiko.SFTPClient.from_transport(transport) Oops, unhandled type 3 ('unimplemented') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.5/dist-packages/paramiko/sftp_client.py", line 165, in from_transport window_size=window_size, max_packet_size=max_packet_size File "/usr/local/lib/python3.5/dist-packages/paramiko/transport.py", line 806, in open_session timeout=timeout, File "/usr/local/lib/python3.5/dist-packages/paramiko/transport.py", line 933, in open_channel raise e File "/usr/local/lib/python3.5/dist-packages/paramiko/transport.py", line 1982, in run ptype, m = self.packetizer.read_message() File "/usr/local/lib/python3.5/dist-packages/paramiko/packet.py", line 441, in read_message header = self.read_all(self.__block_size_in, check_rekey=True) File "/usr/local/lib/python3.5/dist-packages/paramiko/packet.py", line 290, in read_all raise EOFError() EOFError 轻松连接这两个。

当我尝试少输入密码时出现问题。我也试过 master,但是也没有解决。

那么,我在这里缺少明显的东西吗?


这是我由

生成的paramiko日志
10.154.151.252

slave

ssh

0 个答案:

没有答案