-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ScpClient download fails silently when the remote files does not exist #428
Comments
The log is very long and convoluted - can you show what you mean by
|
Apologies for including the entire log. After calling
|
Thank you for the clarification - this sounds very strange - will need to look into it, though there is one more question - what server are you using ? Is it OpenSSH, MINA SSHD itself or something else ?. FYI, in SCP, the server decides on the severity of an error. Our code simply reflects this severity by logging WARNING(s) and throwing exceptions only if server signalled one. Perhaps this is some non-standard implementation of the SCP protocol, or perhaps some non-standard configuration. |
Another question - I see that the command being executed is
What does the "--" stand for ? I am not familiar with this option - usually we copy /some/file1 to /some/file/2 |
Thanks for the response! This testing is being done on macOS (JDK 18) with what I believe is an OpenSSH server. The testing user has no explicit The test I am running is: SshClient sshClient = SshClient.setUpDefaultClient();
sshClient.start();
try (ClientSession session = sshClient.connect("ryanlivingston", "localhost", 22).verify().getClientSession())
{
Path keyPath = Path.of("/Users/ryanlivingston/.ssh/id_rsa");
FileKeyPairProvider keyProvider = new FileKeyPairProvider(keyPath);
Iterable<KeyPair> keyPairs = keyProvider.loadKeys(session);
session.addPublicKeyIdentity(keyPairs.iterator().next());
session.auth().verify();
ScpClient scpClient = DefaultScpClientCreator.INSTANCE.createScpClient(session);
scpClient.download("/Users/ryanlivingston/tmp/null.txt", "/Users/ryanlivingston/tmp/null.download.txt");
} catch (IOException e) {
throw new RuntimeException(e);
} |
I am not sure how that option was generated in the command string. I do not believe I explicelty set that. |
Thanks for the information - I will try and take a look at it when I have some free time (not sure when it will be...) |
ScpClient upload also fails silently for permission denied. Is issue 428 here the same issue as #392? |
Seems likely... |
…led due to missing file or lacking permissions
…led due to missing file or lacking permissions
…led due to missing file or lacking permissions
Here is the problem: the OpenSSH server defines the missing file a WARNING (status=1) rather than an ERROR (status=2):
This also reflected by the log you attached
Therefore the code is correct in not treating this as an error. In order to allow user code to handle this otherwise, we will add a new method to the listener to enable users to reach their own decision. Caveat emptor: due to the way the code is written we can only provide the raw command that caused the error/warning and let the user decide whether to throw an exception or not. Furthermore, I would recommend opening an issue with OpenSSH as to this behavior - perhaps also for PR#392 regarding similar behavior when lacking appropriate permissions to access the file |
…led due to missing file or lacking permissions
…led due to missing file or lacking permissions
…led due to missing file or lacking permissions
Should have been fixed by commit f908189. |
Version
2.11.0
Bug description
When calling
ScpClient.download(String, String)
, the method does not throw any exception or indicate to the caller that the SCP failed when the remote file is not available. Is this the expected behavior?From the logging, we can see a WARNING exit status is received but it is only logged.
Is the expectation here to override the client and handle this warning as the client? Or is it expected that I check the filesystem to determine a status?
Actual behavior
To the client, the API
ScpClient.download(String, String)
behaves no differently if the remote file exists or does not exist.Expected behavior
Some API level indication that the download has failed.
Relevant log output
Other information
No response
The text was updated successfully, but these errors were encountered: