0 votes
by (120 points)

Hi!
Im getting the following error:

java.rmi.RemoteException: No exit status returned for command=pwd

When using an OpenSSH based server ) I could not reproduce the issue, but when using Rebex TinySFTP (and another java based server) the issue does occur.

The problem arises when running the 'pwd' command. In certain SFTP servers, pwd command does not return the response and the call gets hung.

1 Answer

0 votes
by (73.6k points)

Hello,

please note that Rebex products run on Microsoft .NET, however you are getting a java.rmi.RemoteException. Could you please specify:

  1. Which Rebex product you are experiencing issues with:
  • Rebex SFTP client .NET library
  • Rebex SFTP server .NET library
  • Rebex Buru SFTP server application
  • Rebex Tiny SFTP server application
  1. What are you exactly doing, what is expected result and what is actual result?
by (120 points)
HI! Thanks for your answer.

I'm using Rebex SFTP server .NET library.

I are trying to do a LIST with Java, but since I do not have the workingDir, I first execute a PWD command; that's when I get this error.
The app works fine against other SFTP servers.
Thanks!
by (148k points)
Could you please specify what "execute a PWD command" means? Does the client actually attempt to execute the "pwd" command using SSH shell? That is not possible with Rebex Tiny SFTP server, which only supports the SFTP protocol, not SSH shell or remote execute.

If you are compiling Rebex Tiny SFTP server yourself, you can easily add SSH shell support. Just add the following line to https://github.com/rebexnet/RebexTinySftpServer/blob/73da2e8f310433223c9e7b329a95bd866396bc91/TinySftpServer/MainForm.cs#L331 :

    Server.Bind(Config.ServerPort, FileServerProtocol.Shell);
by (120 points)
I'm trying to execute this:

try {
      return session.executeRemoteCommand("pwd").trim();
    } catch (IOException e) {
 
Is not PWD part of the SFTP protocol?
by (148k points)
No, "pwd" command is not part of the SFTP protocol. The SFTP protocol does not even have a concept of "current directory". Commands such as "ls", "dir", "get", "mget" or "mput" are not part of the SFTP protocol either.

Commands used by the "sftp" command line client do not represent actual SFTP protocol's command at all. The "sftp" command line tool was just designed to mimic the well-known "ftp" command line client, and its commands don't match SFTP protocol's requests.

When you call executeRemoteCommand(anything), you are not using the SFTP protocol at all. You are simply executing remote shell commands (such as "pwd") using the SSH server's remote execute functionality.

To get an idea of how SFTP protocol works, check out SFTP v3 specification at https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02 - you won't find "pwd", "cd", "get" there.
...