Paramiko server responds to stat() with FAILURE rather than NO_SUCH_FILE
See original GitHub issueI have a Kotlin/Java application that interacts with several SFTP and FTP servers. SFTP is provided by SSH-2.0-SSHJ_0.34.0. One of these servers is based on: SSH-2.0-paramiko_1.16.0. This server offers only: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1
Searching for an existing resolution, I found issue https://github.com/hierynomus/sshj/issues/670, which gave me a plausible reason for this problem… After some searching around, and failing to get the application’s logger to output SSHJ’s SLF4J output, I reached the point at which the original BufferException is thrown:
ensureAvailable:137, Buffer (net.schmizz.sshj.common)
readUInt32:302, Buffer (net.schmizz.sshj.common)
readUInt32AsInt:297, Buffer (net.schmizz.sshj.common)
readStatusCode:107, Response (net.schmizz.sshj.sftp)
ensurePacketTypeIs:117, Response (net.schmizz.sshj.sftp)
stat:283, SFTPEngine (net.schmizz.sshj.sftp)
stat:227, SFTPEngine (net.schmizz.sshj.sftp)
prepareFile:340, SFTPFileTransfer$Uploader (net.schmizz.sshj.sftp)
uploadFile:256, SFTPFileTransfer$Uploader (net.schmizz.sshj.sftp)
upload:209, SFTPFileTransfer$Uploader (net.schmizz.sshj.sftp)
access$100:192, SFTPFileTransfer$Uploader (net.schmizz.sshj.sftp)
upload:81, SFTPFileTransfer (net.schmizz.sshj.sftp)
upload:76, SFTPFileTransfer (net.schmizz.sshj.sftp)
put:263, SFTPClient (net.schmizz.sshj.sftp)
The value of the target is:
this = Buffer [rpos=21, wpos=24, size=24]
this.data = [101, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 7, 70, 97, 105, 108, 117, 114, 101, 0, 0, 0, 0]
this.type = PacketType.STATUS
this.protocolVersion = 3
this.available() = **3 (yes, not 4!)**
When targeting a test server (SSH-2.0-OpenSSH_9.0, ), everything works perfectly. When using the (debian) sftp CLI application, the upload succeeds. As a result, like @jmatias-assia and yourself, I suspect that there is a problem introduced by the use of diffie-hellman-group1-sha1.
The fault is persistent, and happens on every attempt to put().
Regrettably, the server is not open to the public, so I can’t give you access to it, but I can either do your bidding, or, alternatively, can clone the project and try to find a resolution myself.
Which would you prefer? Be advised that I have no background in cryptography.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (3 by maintainers)
I agree. But I cannot duplicate the “problematic” server, since it is a “homebrew” application made by the vendor of the services it renders (hence the use of the paramiko library).
So I’ll check-out the repo and fix it myself, then make a pull request. The SFTP part of it is (relatively) easy to read. I’ll keep this issue posted with my observations on the way.
Thanks for your help.
One night’s musings later, I think that we are facing a “trident” of issues:
I have created 2 new issues, in order that the wanderings at the beginning do not deter the reader from continuing.
Thanks to @vladimirlagunov for his aid in reaching this point.