sftp: allow silencing no hostkey validation warning

This commit is contained in:
Noah Zalev
2026-07-28 15:47:26 +01:00
committed by Nick Craig-Wood
parent 631bd09ce4
commit 19f8b69518
2 changed files with 8 additions and 3 deletions
+5 -2
View File
@@ -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) {
+3 -1
View File
@@ -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