我使用带有 FTP 连接的 python 脚本工作。我无法使用 ftplib.FTP 和 pysftp 连接到 FTP。
手动 FTP 连接有效,但我必须启用在当前 openSSH 版本中默认禁用的 dss-ssh 算法。我的脚本中缺少哪个配置?
手动连接:
$ sftp -oHostKeyAlgorithms=+ssh-dss ftp_address
我的脚本使用 pysftp:
import pysftp
srv = pysftp.Connection(host=my_host, password=my_pass)
堆栈跟踪:
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 2411, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1802, in run
launch(file, globals, locals) # execute the script
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/ftp_tool.py", line 8, in <module>
srv = pysftp.Connection(host=my_host, password=my_pass)
File "/ftp_service/venv/lib/python3.4/site-packages/pysftp/__init__.py", line 132, in __init__
self._tconnect['hostkey'] = self._cnopts.get_hostkey(host)
File "/ftp_service/venv/lib/python3.4/site-packages/pysftp/__init__.py", line 71, in get_hostkey
raise SSHException("No hostkey for host %s found." % host)
paramiko.ssh_exception.SSHException: No hostkey for host my_host found.
使用 Python 3.4.3