Ich arbeite an einem Python-Skript mit FTP-Verbindung. Ich kann keine Verbindung zum ftp mit ftplib.FTP und pysftp herstellen.Python FTP-Dienstprogramm, das ssh-dss öffentlichen Schlüsselalgorithmus aktiviert
Manuelle FTP-Verbindung funktioniert, aber ich muss den dss-ssh-Algorithmus aktivieren, der in der aktuellen openSSH-Version standardmäßig deaktiviert ist. Welche Konfiguration fehlt in meinem Skript?
Manuelle Verbindung:
$ sftp -oHostKeyAlgorithms=+ssh-dss ftp_address
Mein Skript pysftp:
import pysftp
srv = pysftp.Connection(host=my_host, password=my_pass)
Stack-Trace:
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
Vielleicht könnten Sie versuchen, ['paramiko'] (http://docs.paramiko.org/en/2.4/api/sftp.html#module-paramiko.sftp) – mhawke
In der Tat, wie von mhawke und Martin, I gebrauchte Paramiko. Ein anderes Problem, das ich hatte, ist, dass der Hostname nicht durch Paramiko aufgelöst wurde. Momentan verwende ich die IP-Adresse direkt. Ich werde weiter untersuchen, sollte die Zeit es erlauben. – Tsachi