Open riley-martine opened 1 week ago
Hi Riley,
Thank you for the detailed report. I went ahead an implemented similar logic to the paramiko example and tried adding some tests. I was unable to enable them for now due to pytest-sftpserver limitations. I have a PR that I'm preparing but currently it seems the project is unmaintained so forking may be necessary.
When trying to access a server on a nonstandard port,
sftpretty
fails to check the host keys correctly, and fails to connect. This means I have to disable hostkey checking, which is potentially dangerous.I have a server
server.example.com
that I am trying to access via SFTP on port 2108. Usingsftpretty
:This fails with the following:
paramiko.ssh_exception.SSHException: No hostkey for host [server.example.com] found.
```console Traceback (most recent call last): File "/Users/zero/dev/homebrew-auto-seedbox/./scripts/sftpretty_demo.py", line 16, inThis is because in known_hosts, this server is represented like so:
It needs to be looked up as
[server.example.com]:2108
, but it is being looked up asserver.example.com
.See how
paramiko
's SSH client handles this case:I think the solution is either to delegate hostkey checking to
paramiko
, or to implement the same strategy they use here.OS: MacOS 14.2.1 (23C71) (ARM)
sftpretty
version: 1.1.6Thank you for making this very useful library!