SFTP: Support SSH configuration file

Hi!
I recently started utilizing rclone as a replacement for scp and rsync due to the provided concurrency features and the enormous speedup rclone provides, however the switch to rclone wasn't painless. Previously I utilized SSH configuration (~/.ssh/config) to configure defaults for actively utilized SSH endpoints - provide their SSH keys, usernames, ports etc.

Unfortunately when migrating to rclone, due to the fact that rclone SFTP backend lacks an ability to read SSH config I had to resort to using the command arguments (e.g --sftp-user) or updating the rclone configuration file to duplicate most the the attributes I had already set in existing SSH configuration file.

I have looked through the previous forum discussions and GitHub issues and I haven't seen a similar feature request with regards to SSH config, thus the questions:

  1. Are you interested in the ability to automatically read SSH config when using the SFTP backend?
  2. Are there any reasons why such ability hasn't been implemented?

Thanks!

This hasn't been implemented because rclone doesn't use the ssh libraries - it uses a memory safe Go re-implementation of the ssh protocol.

The ~/.ssh/config is very powerful and implementing it all would be a huge amount of work.

You can use rclone aliases to help ease the transition though and you can use rclone configs.

You can also define the settings in a connection string which is something I use a lot with sftp, eg :sftp,host=whatever:

Hi @ncw,
Thanks for your feedback! I am aware of the possibility to define settings in connection strings and aliases, however that is still something what must be adjusted manually. If it was possible to provide a flag e.g --sftp-load-ssh-config it would be amazing.

I understand that currently rclone doesn't use system SSH libraries - I've taken a look at pkg/sftp and x/crypto/ssh backends being currently being utilized for SFTP backend.

The ~/.ssh/config is very powerful and implementing it all would be a huge amount of work.

I agree that implementing SSH configuration support fully would be an insane amount of work and would considerably decrease the SFTP backend's maintainability. To lower the amount of work required - what are your thoughts if support is provided only for most popular SSH configuration options, e.g:

  • Username;
  • Hostname;
  • IdentityFile;
  • Port;
  • Timeout;
  • UserKnownHostsFile?

Given that an existing, maintained implementation for parsing SSH configuration file options exists (e.g kevinburke/ssh_config) it might be easier to implement the bare minimum featureset.
Do you have any objections against introducing a new dependency on a maintained Go project which takes care of parsing the SSH configuration?

I'm asking since I might be interested in implementing the ability to read SSH configuration myself - as long as you don't have any objections in introducing such dependencies and you think that this feature would be something what would fit in with rclone featureset.

Thanks!

Sounds great if you want to have a go at it.

This probably needs to be enabled with a flag. Say ssh_config then you could use it in a connection string like

:sftp,ssh_config,host=blah:

Or

:sftp: --sftp-ssh-config --sftp-host blah

How did that sound?

Hmm or maybe combine the two --sftp-ssh-host blah

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.