From f9306218f877253df2dc561f8061ac4591f8f2e7 Mon Sep 17 00:00:00 2001 From: Zac Rubin Date: Thu, 11 Jun 2020 12:05:30 +0100 Subject: [PATCH] sftp: Fix SSH key PEM loading For SSH authentication, `key_pem` should both override `key_file` and not require other SSH authentication methods to be set. Prior to this fix, rclone would attempt to use an ssh-agent when `key_pem` was the only SSH authentication method set. Fixes #4240 --- backend/sftp/sftp.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go index e3a631a25..51d03de08 100644 --- a/backend/sftp/sftp.go +++ b/backend/sftp/sftp.go @@ -395,8 +395,8 @@ func NewFs(name, root string, m configmap.Mapper) (fs.Fs, error) { keyFile := env.ShellExpand(opt.KeyFile) //keyPem := env.ShellExpand(opt.KeyPem) - // Add ssh agent-auth if no password or file specified - if (opt.Pass == "" && keyFile == "" && !opt.AskPassword) || opt.KeyUseAgent { + // Add ssh agent-auth if no password or file or key PEM specified + if (opt.Pass == "" && keyFile == "" && !opt.AskPassword && opt.KeyPem == "") || opt.KeyUseAgent { sshAgentClient, _, err := sshagent.New() if err != nil { return nil, errors.Wrap(err, "couldn't connect to ssh-agent")