我是python的初学者,我希望通过SFTP协议自动化从我的计算机(windows 1021H2)到Linux服务器(Rocky Linux8.6)的文件传输。我使用带有密码的密钥对进行身份验证。
连接不成功。我尝试了很多组合,也经历了很多关于堆叠溢出的问题,但没有成功.
import pysftp
host,port = 'monServeur.domaine.fr',22
username='pmartin'
pkey='C:/Users/pmartin/.ssh/myPrivateKey'
passphrase='mypassphrase'
with pysftp.Connection(host=host, username=username, private_key=pkey, port=22, private_key_pass=passphrase) as sftp:
with sftp.cwd('/home/pmartin'):
for entry in sftp.listdir_attr():
print(entry.filename)
返回的错误:
C:\programmation\python>"C:/Program Files/Python310/python.exe" c:/programmation/python/ftptls.py
Exception (client): Incompatible ssh server (no acceptable ciphers)
Traceback (most recent call last):
File "C:\Users\omarie\AppData\Roaming\Python\Python310\site-packages\paramiko\transport.py", line 2138, in run
self._handler_table[ptype](self, m)
File "C:\Users\omarie\AppData\Roaming\Python\Python310\site-packages\paramiko\transport.py", line 2258, in _negotiate_keys
self._parse_kex_init(m)
File "C:\Users\omarie\AppData\Roaming\Python\Python310\site-packages\paramiko\transport.py", line 2511, in _parse_kex_init
raise IncompatiblePeer(
paramiko.ssh_exception.IncompatiblePeer: Incompatible ssh server (no acceptable ciphers)
Traceback (most recent call last):
File "c:\programmation\python\ftptls.py", line 9, in <module>
with pysftp.Connection(host, username, pkey, None, 22, passphrase, ['aes128-cbc','aes192-cbc','aes256-cbc','aes128-ctr','aes192-ctr','aes256-ctr']) as sftp:
File "C:\Users\omarie\AppData\Roaming\Python\Python310\site-packages\pysftp\__init__.py", line 143, in __init__
self._transport.connect(**self._tconnect)
File "C:\Users\omarie\AppData\Roaming\Python\Python310\site-packages\paramiko\transport.py", line 1346, in connect
self.start_client()
File "C:\Users\omarie\AppData\Roaming\Python\Python310\site-packages\paramiko\transport.py", line 699, in start_client
raise e
File "C:\Users\omarie\AppData\Roaming\Python\Python310\site-packages\paramiko\transport.py", line 2138, in run
self._handler_table[ptype](self, m)
File "C:\Users\omarie\AppData\Roaming\Python\Python310\site-packages\paramiko\transport.py", line 2258, in _negotiate_keys
self._parse_kex_init(m)
File "C:\Users\omarie\AppData\Roaming\Python\Python310\site-packages\paramiko\transport.py", line 2511, in _parse_kex_init
raise IncompatiblePeer(
paramiko.ssh_exception.IncompatiblePeer: Incompatible ssh server (no acceptable ciphers)
版本:
Python3.10.4(tag/v3.10.4:9d38120,MAR232022,23:13:41) MSC v.1929 64位(AMD64) on win32
单元:
服务器上的密码:
[monServeur ~/.ssh]$ ssh -Q cipher
3des-cbc
aes128-cbc
aes192-cbc
aes256-cbc
rijndael-cbc@lysator.liu.se
aes128-ctr
aes192-ctr
aes256-ctr
aes128-gcm@openssh.com
aes256-gcm@openssh.com
chacha20-poly1305@openssh.com
我试图像这样在pysftp命令中添加密码,但没有成功:
with pysftp.Connection(host, username, pkey, None, 22, passphrase, ['aes128-cbc','aes192-cbc','aes256-cbc','aes128-ctr','aes192-ctr','aes256-ctr']) as sftp:
我可以用FileZilla和数码鸭完成我的传输,没有这个“密码问题”,密钥对和密码。
谁能给我个线索吗?
添加: paramiko日志文件
DEBUG:paramiko.transport:starting thread (client mode): 0x1bf1a6b0
DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.11.0
DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-OpenSSH_8.0
INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_8.0)
DEBUG:paramiko.transport:=== Key exchange possibilities ===
DEBUG:paramiko.transport:kex algos: curve25519-sha256@libssh.org
DEBUG:paramiko.transport:server key: rsa-sha2-512, rsa-sha2-256, ssh-rsa, ssh-ed25519
DEBUG:paramiko.transport:client encrypt: chacha20-poly1305@openssh.com, aes256-gcm@openssh.com
DEBUG:paramiko.transport:server encrypt: chacha20-poly1305@openssh.com, aes256-gcm@openssh.com
DEBUG:paramiko.transport:client mac: hmac-sha2-512-etm@openssh.com, hmac-sha2-256-etm@openssh.com
DEBUG:paramiko.transport:server mac: hmac-sha2-512-etm@openssh.com, hmac-sha2-256-etm@openssh.com
DEBUG:paramiko.transport:client compress: none, zlib@openssh.com
DEBUG:paramiko.transport:server compress: none, zlib@openssh.com
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: curve25519-sha256@libssh.org
DEBUG:paramiko.transport:HostKey: ssh-ed25519
ERROR:paramiko.transport:Exception (client): Incompatible ssh server (no acceptable ciphers)
发布于 2022-06-30 10:47:40
您的服务器只支持两个专有的OpenSSH密码:
DEBUG:paramiko.transport:client encrypt: chacha20-poly1305@openssh.com, aes256-gcm@openssh.com
DEBUG:paramiko.transport:server encrypt: chacha20-poly1305@openssh.com, aes256-gcm@openssh.com
这确实是相当有限的设定。
帕拉米科不支持这些。
您必须重新配置服务器,以支持Paramiko所做的一些密码。
https://stackoverflow.com/questions/72815674
复制相似问题