sftp: Add --ssh-path-override flag #1474

The flag allows calculation of checksums on systems using
different paths for SSH and SFTP, like synology NAS boxes.
This commit is contained in:
Piotr Oleszczyk 2018-04-30 18:05:10 +02:00 committed by Nick Craig-Wood
parent 0479c7dcf5
commit 76f2cbeb94
2 changed files with 18 additions and 0 deletions

View File

@ -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()

View File

@ -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.