Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

sftp: Add option to disable remote hash check command execution

Jon Fautley36e6d2311282
diff --git a/docs/content/sftp.md b/docs/content/sftp.md
index 4f58cc70f..3c984744c 100644
--- a/docs/content/sftp.md
+++ b/docs/content/sftp.md
@@ -151,6 +151,10 @@ Modified times are used in syncing and are fully supported.
SFTP supports checksums if the same login has shell access and `md5sum`
or `sha1sum` as well as `echo` are in the remote's PATH.
+This remote check can be disabled by setting the configuration option
+`disable_hashcheck`. This may be required if you're connecting to SFTP servers
+which are not under your control, and to which the execution of remote commands
+is prohibited.
The only ssh agent supported under Windows is Putty's pageant.
diff --git a/sftp/sftp.go b/sftp/sftp.go
index 5d424c5d1..08cef3705 100644
--- a/sftp/sftp.go
+++ b/sftp/sftp.go
@@ -70,6 +70,10 @@ func init() {
Help: "Enables the use of the aes128-cbc cipher.",
},
},
+ }, {
+ Name: "disable_hashcheck",
+ Help: "Disable the exectution of SSH commands to determine if remote file hashing is available, leave blank unless you know what you are doing.",
+ Optional: true,
}},
}
fs.Register(fsi)
@@ -613,6 +617,11 @@ func (f *Fs) Hashes() fs.HashSet {
return *f.cachedHashes
}
+ hashcheckDisabled := fs.ConfigFileGetBool(f.name, "disable_hashcheck")
+ if hashcheckDisabled {
+ return fs.HashSet(fs.HashNone)
+ }
+
c, err := f.getSftpConnection()
if err != nil {
fs.Errorf(f, "Couldn't get SSH connection to figure out Hashes: %v", err)