question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Paramiko server responds to stat() with FAILURE rather than NO_SUCH_FILE

See original GitHub issue

I 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:closed
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ghherlincommented, Sep 23, 2022

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.

0reactions
ghherlincommented, Sep 24, 2022

One night’s musings later, I think that we are facing a “trident” of issues:

  1. how to deal best with the vagaries and errors in the plethora of servers faced by SSH4J
  2. how to fix the error-reporting issue identified above
  3. How to reduce the time wasted in the diagnostic of these 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Paramiko get() raises IOError "No such file" if server doesn't ...
I got the error, "FileNotFoundError: [Errno 2] No such file", with my code running on Windows machines but not on macOS computers. My...
Read more >
Writing in append mode fails on TypeError when stat does not ...
stat() raises FileNotFoundError: [Errno 2] No such file when the given path is not found (using OpenSSH server). I think sftp server on...
Read more >
SFTP - Paramiko documentation
stat , except it's called on an open file instead of a path. Returns: an attributes object for the given file, or an...
Read more >
Frequently Asked Questions — Ansible Documentation
Here are some commonly asked questions and their answers. Where did all the modules go? . In July, 2019, we announced that...
Read more >
How can I automatically change directory on ssh login?
You can put the cd command in ~/.bashrc at the remote server instead. – vdboor. Aug 5, 2010 at 16:00.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found