diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go index 51a7e7c98..38acd3ad8 100644 --- a/backend/sftp/sftp.go +++ b/backend/sftp/sftp.go @@ -41,6 +41,7 @@ var ( // Flags sftpAskPassword = flags.BoolP("sftp-ask-password", "", false, "Allow asking for SFTP password when needed.") + sshPathOverride = flags.StringP("ssh-path-override", "", "", "Override path used by SSH connection.") ) func init() { @@ -763,6 +764,9 @@ func (o *Object) Hash(r hash.Type) (string, error) { session.Stdout = &stdout session.Stderr = &stderr escapedPath := shellEscape(o.path()) + if *sshPathOverride != "" { + escapedPath = shellEscape(path.Join(*sshPathOverride, o.remote)) + } err = session.Run(hashCmd + " " + escapedPath) if err != nil { _ = session.Close() diff --git a/docs/content/sftp.md b/docs/content/sftp.md index bcd766020..811063121 100644 --- a/docs/content/sftp.md +++ b/docs/content/sftp.md @@ -155,6 +155,20 @@ Here are the command line options specific to this remote. Ask for the SFTP password if needed when no password has been configured. +#### --ssh-path-override #### + +Override path used by SSH connection. Allows checksum calculation when +SFTP and SSH paths are different. This issue affects among others Synology +NAS boxes. + +Shared folders can be found in directories representing volumes + + rclone sync /home/local/directory remote:/directory --ssh-path-override /volume2/directory + +Home directory can be found in a shared folder called `homes` + + rclone sync /home/local/directory remote:/home/directory --ssh-path-override /volume1/homes/USER/directory + ### Modified time ### Modified times are stored on the server to 1 second precision.