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: allow silencing no hostkey validation warning

Noah Zalev19f8b695180c
diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go
index cd118f1f4..636728665 100644
--- a/backend/sftp/sftp.go
+++ b/backend/sftp/sftp.go
@@ -120,7 +120,7 @@ Set this if you have a signed certificate you want to use for authentication.` +
Name: "known_hosts_file",
Help: `Optional path to known_hosts file.
-Set this value to enable server host key validation.` + env.ShellExpandHelp,
+Set this value to enable server host key validation. Set to ` + "`none`" + ` to silence the "No host key validation" notice.` + env.ShellExpandHelp,
Advanced: true,
Examples: []fs.OptionExample{{
Value: "~/.ssh/known_hosts",
@@ -1312,6 +1312,9 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
}
switch {
+ case opt.KnownHostsFile == "none":
+ // Silence Host key validation warning if explicitly disabled
+ sshConfig.HostKeyCallback = ssh.InsecureIgnoreHostKey()
case opt.KnownHostsFile != "":
hostcallback, err := knownhosts.New(env.ShellExpand(opt.KnownHostsFile))
if err != nil {
@@ -1336,7 +1339,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
}
default:
sshConfig.HostKeyCallback = ssh.InsecureIgnoreHostKey()
- fs.Logf(name, "No host key validation is being performed. Set known_hosts_file or use --sftp-pin-host-key to enable it. See: https://rclone.org/sftp/#host-key-validation")
+ fs.Logf(name, "No host key validation is being performed. Set known_hosts_file (to \"none\" to silence this notice) or use --sftp-pin-host-key to enable it. See: https://rclone.org/sftp/#host-key-validation")
}
if opt.UseInsecureCipher && (opt.Ciphers != nil || opt.KeyExchange != nil) {
diff --git a/docs/content/sftp.md b/docs/content/sftp.md
index 4cccb91d2..9e2173b51 100644
--- a/docs/content/sftp.md
+++ b/docs/content/sftp.md
@@ -216,7 +216,9 @@ is being performed` each time the backend is started in this mode.
Host key matching, using standard ssh `known_hosts` files can be
turned on by enabling the `known_hosts_file` option. This can point to
-the file maintained by `OpenSSH` or can point to a unique file.
+the file maintained by `OpenSSH` or can point to a unique file. To
+explicitly disable host key checking and silence the warning, the
+`known_hosts_file` option can be set to `none`.
Alternatively rclone can maintain server host keys in a `host_keys`
setting in the config file. This can be updated automatically with