Open sibiarunachalam opened 6 years ago
It looks purely SSH Server configuration problem. It worked in Windows after setting Mount Points in SSH Server
But, I didn't get any clue for Linux. It throws same exception when I try to get files in "fooDir" from foouser's HOME dir I expect, sshj should get "fooDir" from user's home directory by default
I'm not sure I'm following you. Can you write a clear problem description?
Don't know whether this was @sibiarunachalam's issue, as the stack trace is slightly different, and I'm trying to get a regular file, not a directory, but I just worked through the following thing that sounds similar:
sftpClient.put("./local_file.txt", "remote_file.txt")
succeeds./somedir/remote_file.txt
, where /somedir
is the user's default remote working directory.sftpClient.get("remote_file.txt", "./whatever.txt")
fails with SFTPException: No such file
, stacktrace below.sftpClient.open("remote_file.txt").read(...)
succeeds. This is what I'm now using.sftpClient.canonicalize("remote_file.txt")
fails with SFTPException: No such file
.In debugging I found that both canonicalize
and get
internally result in an attempt to use the path /remote_file.txt
—note the incorrect leading /
.
Edit: I also confirmed that sftpClient.get("/somedir/remote_file.txt", "./local.txt")
succeeds, but I didn't see a way to determine the canonical remote path programmatically.
net.schmizz.sshj.sftp.SFTPException: No such file
at net.schmizz.sshj.sftp.Response.error(Response.java:137)
at net.schmizz.sshj.sftp.Response.ensurePacketTypeIs(Response.java:114)
at net.schmizz.sshj.sftp.SFTPEngine.open(SFTPEngine.java:143)
at net.schmizz.sshj.sftp.SFTPEngine.open(SFTPEngine.java:149)
at net.schmizz.sshj.sftp.SFTPEngine.open(SFTPEngine.java:154)
at net.schmizz.sshj.sftp.SFTPFileTransfer$Downloader.downloadFile(SFTPFileTransfer.java:134)
at net.schmizz.sshj.sftp.SFTPFileTransfer$Downloader.download(SFTPFileTransfer.java:105)
at net.schmizz.sshj.sftp.SFTPFileTransfer$Downloader.access$300(SFTPFileTransfer.java:90)
at net.schmizz.sshj.sftp.SFTPFileTransfer.download(SFTPFileTransfer.java:71)
at net.schmizz.sshj.sftp.SFTPFileTransfer.download(SFTPFileTransfer.java:59)
at net.schmizz.sshj.sftp.SFTPClient.get(SFTPClient.java:229)
Which version are you using?
com.hierynomus:sshj:0.26.0
Also, I found that ./remote_file.txt
works, just not remote_file.txt
.
sshj version: 0.21.0 Client: Linux SSH Server: Linux Or Windows (Tested in both OS) Code:
Exception:
Note: It works with SCPFileTransfer