Key_file with key_use_agent doesn't work

What is the problem you are having with rclone?

I'm registering many keys in ssh-agent, and I want to connect sftp server with a private keys with passphrase.
If I don't specify any key information (path or passphrase, etc.), rclone tries all the keys in ssh-agent and fail with Too many authentication failures (this is intended and OK).
Then, according to rclone's wizard, the solutions for this is using key_file with key_use_agent. That is, I specify the path for the key (with passphrase) and force the use of ssh-agent, and rclone would choose the right key from ssh-agent.
However, when I set up things like this, rclone says "failed to parse private key file: ssh: this private key is passphrase protected".
I can connect with normal ssh command with IdentitiesOnly=yes and -i .ssh/id_ecdsa (without entering passphrase).
Please help me.

Run the command 'rclone version' and share the full output of the command.

rclone version 1.61.1
I tested both in Linux and Windows

Which cloud storage system are you using? (eg Google Drive)


The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone mount servername:/ mountpoint/ -vv

The rclone config contents with secrets removed.

type = sftp
host = localhost
user = username
key_file = ~/.ssh/id_ecdsa
key_use_agent = true
port = 5995
shell_type = unix
md5sum_command = md5 -r
sha1sum_command = none
#pubkey_file = ~/.ssh/

A log from the command with the -vv flag

2023/02/24 11:19:52 DEBUG : rclone: Version "v1.61.1" starting with parameters ["rclone" "mount" "servername:/" "mountpoint/" "-vv"]
2023/02/24 11:19:52 DEBUG : Creating backend with remote "servername:/"
2023/02/24 11:19:52 DEBUG : Using config file from "/home/user/.config/rclone/rclone.conf"
2023/02/24 11:19:52 Failed to create file system for "servername:/": failed to parse private key file: ssh: this private key is passphrase protected

What does the start of your key_file look like?

Mine (which is encrypted) looks like this

Proc-Type: 4,ENCRYPTED

My key_file (.ssh/id_ecdsa) looks like this:


(openssh format always begins with b3BlbnNzaC1rZXktdjEAAAAA.)

I'd probably strace rclone next to see which files rclone is opening to make sure it is opening the right one.