Operations/list for SFTP gives error but command line "ls" works

Hello Experts,

We are using 'rclone-v1.68.2' and 'rclone-v1.63.1' in both below behavior is same -

Have created a remote for SFTP (azure service) and trying to list files inside of SFTP path.

In command line mode it works as expected :-

But if I try to list same directory using remote mode api :-

It always gives 404 error.

What could be the reason for this? Am I missing anyting here?
Suggestions is much appreciated.

Thanks,
Mahendra

Not sure.. things to try

Try without the _filter

Try without the / on the end of the remote

Try with -vv on the rclone rcd and check the log

1 Like

Thank you @ncw for the quick response -

I tried removing "_filter" and "/" but that did not make any difference.

Logs -
2025/01/11 11:56:14 DEBUG : rclone: Version "v1.63.1" starting with parameters ["rclone.exe" "rcd" "--rc-no-auth" "--rc-job-expire-duration=60m" "--rc-addr=localhost:5574" "--log-file" "mhsftp_3.log" "--log-level" "DEBUG"]
2025/01/11 11:56:14 NOTICE: Serving remote control on http://127.0.0.1:5574/
2025/01/11 11:56:18 DEBUG : rc: "operations/list": with parameters map[fs:telerm: remote:/Teleflex/Preprod/InBound/]
2025/01/11 11:56:18 DEBUG : Creating backend with remote "telerm:"
2025/01/11 11:56:18 DEBUG : Using config file from "C:\Users\mahendra.hegde\AppData\Roaming\rclone\rclone.conf"
2025/01/11 11:56:19 DEBUG : sftp://xxxxxxxxx.svco9mycompname@xxxxxxxxx.blob.core.windows.net:22/: New connection 192.168.0.156:52745->20.209.14.65:22 to "SSH-2.0-AzureSSH_1.0.0"
2025/01/11 11:56:20 DEBUG : sftp://xxxxxxxxx.svco9mycompname@xxxxxxxxx.blob.core.windows.net:22/: Shell type "unix" from config
2025/01/11 11:56:20 DEBUG : sftp://xxxxxxxxx.svco9mycompname@xxxxxxxxx.blob.core.windows.net:22/: Relative path resolved to "/mycompname"
2025/01/11 11:56:20 DEBUG : sftp://xxxxxxxxx.svco9mycompname@xxxxxxxxx.blob.core.windows.net:22/: Using root directory "/mycompname"
2025/01/11 11:56:20 ERROR : /Teleflex/Preprod/InBound/: error listing: directory not found
2025/01/11 11:56:20 ERROR : rc: "operations/list": error: error in ListJSON: directory not found

I have an idea...

Move the / at the start of the remote to the end of the fs

fs=telerm:/
remote=Teleflex/Preprod/InBound/

The sftp backend cares about that / without it, it will be looking in the home directory of the user and maybe it is being stripped off the remote.

Thank you @ncw this trick worked !

This request gave expected response :smiley:
{
"fs": "telerm:/",
"remote": "/Teleflex/Preprod/InBound"
}

Thing to note that -
{
"fs": "telerm:/",
"remote": "/Teleflex/Preprod/InBound/"
}
resulted in empty array response (instead of listing the files)

Where as in command line -

  1. D:\Software\rclone-v1.68.2-windows-amd64>rclone.exe ls telerm:/Teleflex/Preprod/InBound
  2. D:\Software\rclone-v1.68.2-windows-amd64>rclone.exe ls telerm:/Teleflex/Preprod/InBound/

Both of these command gave correct result (listed all files)

Thank you once again for your such a quick response @ncw

1 Like