Python FTP util,支持ssh-dss公钥算法

问题描述 投票:1回答:1

我使用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

python ftp sftp pysftp
1个回答
1
投票

SFTP和FTP是两个完全不相关的协议。

您无法使用FTP协议(ftplib)连接到SFTP服务器。

pysftp / Paramiko应该工作。如果没有,请发布一个关于pysftp / Paramiko的新问题,详细信息。

© www.soinside.com 2019 - 2024. All rights reserved.