github.com/artpar/rclone@v1.67.3/docs/content/sftp.md (about)

     1  ---
     2  title: "SFTP"
     3  description: "SFTP"
     4  versionIntroduced: "v1.36"
     5  ---
     6  
     7  # {{< icon "fa fa-server" >}} SFTP
     8  
     9  SFTP is the [Secure (or SSH) File Transfer
    10  Protocol](https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol).
    11  
    12  The SFTP backend can be used with a number of different providers:
    13  
    14  {{< provider_list >}}
    15  {{< provider name="Hetzner Storage Box" home="https://www.hetzner.com/storage/storage-box" config="/sftp/#hetzner-storage-box">}}
    16  {{< provider name="rsync.net" home="https://rsync.net/products/rclone.html" config="/sftp/#rsync-net">}}
    17  {{< /provider_list >}}
    18  
    19  SFTP runs over SSH v2 and is installed as standard with most modern
    20  SSH installations.
    21  
    22  Paths are specified as `remote:path`. If the path does not begin with
    23  a `/` it is relative to the home directory of the user.  An empty path
    24  `remote:` refers to the user's home directory. For example, `rclone lsd remote:` 
    25  would list the home directory of the user configured in the rclone remote config 
    26  (`i.e /home/sftpuser`). However, `rclone lsd remote:/` would list the root 
    27  directory for remote machine (i.e. `/`)
    28  
    29  Note that some SFTP servers will need the leading / - Synology is a
    30  good example of this. rsync.net and Hetzner, on the other hand, requires users to
    31  OMIT the leading /.
    32  
    33  Note that by default rclone will try to execute shell commands on
    34  the server, see [shell access considerations](#shell-access-considerations).
    35  
    36  ## Configuration
    37  
    38  Here is an example of making an SFTP configuration.  First run
    39  
    40      rclone config
    41  
    42  This will guide you through an interactive setup process.
    43  
    44  ```
    45  No remotes found, make a new one?
    46  n) New remote
    47  s) Set configuration password
    48  q) Quit config
    49  n/s/q> n
    50  name> remote
    51  Type of storage to configure.
    52  Choose a number from below, or type in your own value
    53  [snip]
    54  XX / SSH/SFTP
    55     \ "sftp"
    56  [snip]
    57  Storage> sftp
    58  SSH host to connect to
    59  Choose a number from below, or type in your own value
    60   1 / Connect to example.com
    61     \ "example.com"
    62  host> example.com
    63  SSH username
    64  Enter a string value. Press Enter for the default ("$USER").
    65  user> sftpuser
    66  SSH port number
    67  Enter a signed integer. Press Enter for the default (22).
    68  port>
    69  SSH password, leave blank to use ssh-agent.
    70  y) Yes type in my own password
    71  g) Generate random password
    72  n) No leave this optional password blank
    73  y/g/n> n
    74  Path to unencrypted PEM-encoded private key file, leave blank to use ssh-agent.
    75  key_file>
    76  Remote config
    77  --------------------
    78  [remote]
    79  host = example.com
    80  user = sftpuser
    81  port =
    82  pass =
    83  key_file =
    84  --------------------
    85  y) Yes this is OK
    86  e) Edit this remote
    87  d) Delete this remote
    88  y/e/d> y
    89  ```
    90  
    91  This remote is called `remote` and can now be used like this:
    92  
    93  See all directories in the home directory
    94  
    95      rclone lsd remote:
    96  
    97  See all directories in the root directory
    98  
    99      rclone lsd remote:/
   100  
   101  Make a new directory
   102  
   103      rclone mkdir remote:path/to/directory
   104  
   105  List the contents of a directory
   106  
   107      rclone ls remote:path/to/directory
   108  
   109  Sync `/home/local/directory` to the remote directory, deleting any
   110  excess files in the directory.
   111  
   112      rclone sync --interactive /home/local/directory remote:directory
   113  
   114  Mount the remote path `/srv/www-data/` to the local path
   115  `/mnt/www-data`
   116  
   117      rclone mount remote:/srv/www-data/ /mnt/www-data
   118  
   119  ### SSH Authentication
   120  
   121  The SFTP remote supports three authentication methods:
   122  
   123    * Password
   124    * Key file, including certificate signed keys
   125    * ssh-agent
   126  
   127  Key files should be PEM-encoded private key files. For instance `/home/$USER/.ssh/id_rsa`.
   128  Only unencrypted OpenSSH or PEM encrypted files are supported.
   129  
   130  The key file can be specified in either an external file (key_file) or contained within the 
   131  rclone config file (key_pem).  If using key_pem in the config file, the entry should be on a
   132  single line with new line ('\n' or '\r\n') separating lines.  i.e.
   133  
   134      key_pem = -----BEGIN RSA PRIVATE KEY-----\nMaMbaIXtE\n0gAMbMbaSsd\nMbaass\n-----END RSA PRIVATE KEY-----
   135  
   136  This will generate it correctly for key_pem for use in the config:
   137  
   138      awk '{printf "%s\\n", $0}' < ~/.ssh/id_rsa
   139  
   140  If you don't specify `pass`, `key_file`, or `key_pem` or `ask_password` then
   141  rclone will attempt to contact an ssh-agent. You can also specify `key_use_agent`
   142  to force the usage of an ssh-agent. In this case `key_file` or `key_pem` can
   143  also be specified to force the usage of a specific key in the ssh-agent.
   144  
   145  Using an ssh-agent is the only way to load encrypted OpenSSH keys at the moment.
   146  
   147  If you set the `ask_password` option, rclone will prompt for a password when
   148  needed and no password has been configured.
   149  
   150  #### Certificate-signed keys
   151  
   152  With traditional key-based authentication, you configure your private key only,
   153  and the public key built into it will be used during the authentication process.
   154  
   155  If you have a certificate you may use it to sign your public key, creating a
   156  separate SSH user certificate that should be used instead of the plain public key
   157  extracted from the private key. Then you must provide the path to the
   158  user certificate public key file in `pubkey_file`.
   159  
   160  Note: This is not the traditional public key paired with your private key,
   161  typically saved as `/home/$USER/.ssh/id_rsa.pub`. Setting this path in
   162  `pubkey_file` will not work.
   163  
   164  Example:
   165  
   166  ```
   167  [remote]
   168  type = sftp
   169  host = example.com
   170  user = sftpuser
   171  key_file = ~/id_rsa
   172  pubkey_file = ~/id_rsa-cert.pub
   173  ````
   174  
   175  If you concatenate a cert with a private key then you can specify the
   176  merged file in both places.
   177  
   178  Note: the cert must come first in the file.  e.g.
   179  
   180  ```
   181  cat id_rsa-cert.pub id_rsa > merged_key
   182  ```
   183  
   184  ### Host key validation
   185  
   186  By default rclone will not check the server's host key for validation.  This
   187  can allow an attacker to replace a server with their own and if you use
   188  password authentication then this can lead to that password being exposed.
   189  
   190  Host key matching, using standard `known_hosts` files can be turned on by
   191  enabling the `known_hosts_file` option.  This can point to the file maintained
   192  by `OpenSSH` or can point to a unique file.
   193  
   194  e.g. using the OpenSSH `known_hosts` file:
   195  
   196  ```
   197  [remote]
   198  type = sftp
   199  host = example.com
   200  user = sftpuser
   201  pass = 
   202  known_hosts_file = ~/.ssh/known_hosts
   203  ````
   204  
   205  Alternatively you can create your own known hosts file like this:
   206  
   207  ```
   208  ssh-keyscan -t dsa,rsa,ecdsa,ed25519 example.com >> known_hosts
   209  ```
   210  
   211  There are some limitations:
   212  
   213  * `rclone` will not _manage_ this file for you.  If the key is missing or
   214  wrong then the connection will be refused.
   215  * If the server is set up for a certificate host key then the entry in
   216  the `known_hosts` file _must_ be the `@cert-authority` entry for the CA
   217  
   218  If the host key provided by the server does not match the one in the
   219  file (or is missing) then the connection will be aborted and an error
   220  returned such as
   221  
   222      NewFs: couldn't connect SSH: ssh: handshake failed: knownhosts: key mismatch
   223  
   224  or
   225  
   226      NewFs: couldn't connect SSH: ssh: handshake failed: knownhosts: key is unknown
   227  
   228  If you see an error such as
   229  
   230      NewFs: couldn't connect SSH: ssh: handshake failed: ssh: no authorities for hostname: example.com:22
   231  
   232  then it is likely the server has presented a CA signed host certificate
   233  and you will need to add the appropriate `@cert-authority` entry.
   234  
   235  The `known_hosts_file` setting can be set during `rclone config` as an
   236  advanced option.
   237  
   238  ### ssh-agent on macOS
   239  
   240  Note that there seem to be various problems with using an ssh-agent on
   241  macOS due to recent changes in the OS.  The most effective work-around
   242  seems to be to start an ssh-agent in each session, e.g.
   243  
   244      eval `ssh-agent -s` && ssh-add -A
   245  
   246  And then at the end of the session
   247  
   248      eval `ssh-agent -k`
   249  
   250  These commands can be used in scripts of course.
   251  
   252  ### Shell access
   253  
   254  Some functionality of the SFTP backend relies on remote shell access,
   255  and the possibility to execute commands. This includes [checksum](#checksum),
   256  and in some cases also [about](#about-command). The shell commands that
   257  must be executed may be different on different type of shells, and also
   258  quoting/escaping of file path arguments containing special characters may
   259  be different. Rclone therefore needs to know what type of shell it is,
   260  and if shell access is available at all.
   261  
   262  Most servers run on some version of Unix, and then a basic Unix shell can
   263  be assumed, without further distinction. Windows 10, Server 2019, and later
   264  can also run a SSH server, which is a port of OpenSSH (see official
   265  [installation guide](https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse)). On a Windows server the shell handling is different: Although it can also
   266  be set up to use a Unix type shell, e.g. Cygwin bash, the default is to
   267  use Windows Command Prompt (cmd.exe), and PowerShell is a recommended
   268  alternative. All of these have behave differently, which rclone must handle.
   269  
   270  Rclone tries to auto-detect what type of shell is used on the server,
   271  first time you access the SFTP remote. If a remote shell session is
   272  successfully created, it will look for indications that it is CMD or
   273  PowerShell, with fall-back to Unix if not something else is detected.
   274  If unable to even create a remote shell session, then shell command
   275  execution will be disabled entirely. The result is stored in the SFTP
   276  remote configuration, in option `shell_type`, so that the auto-detection
   277  only have to be performed once. If you manually set a value for this
   278  option before first run, the auto-detection will be skipped, and if
   279  you set a different value later this will override any existing.
   280  Value `none` can be set to avoid any attempts at executing shell
   281  commands, e.g. if this is not allowed on the server.
   282  If you have `shell_type = none` in the configuration then
   283  the [ssh](#sftp-ssh) must not be set.
   284  
   285  When the server is [rclone serve sftp](/commands/rclone_serve_sftp/),
   286  the rclone SFTP remote will detect this as a Unix type shell - even
   287  if it is running on Windows. This server does not actually have a shell,
   288  but it accepts input commands matching the specific ones that the
   289  SFTP backend relies on for Unix shells, e.g. `md5sum` and `df`. Also
   290  it handles the string escape rules used for Unix shell. Treating it
   291  as a Unix type shell from a SFTP remote will therefore always be
   292  correct, and support all features.
   293  
   294  #### Shell access considerations
   295  
   296  The shell type auto-detection logic, described above, means that
   297  by default rclone will try to run a shell command the first time
   298  a new sftp remote is accessed. If you configure a sftp remote
   299  without a config file, e.g. an [on the fly](/docs/#backend-path-to-dir])
   300  remote, rclone will have nowhere to store the result, and it
   301  will re-run the command on every access. To avoid this you should
   302  explicitly set the `shell_type` option to the correct value,
   303  or to `none` if you want to prevent rclone from executing any
   304  remote shell commands.
   305  
   306  It is also important to note that, since the shell type decides
   307  how quoting and escaping of file paths used as command-line arguments
   308  are performed, configuring the wrong shell type may leave you exposed
   309  to command injection exploits. Make sure to confirm the auto-detected
   310  shell type, or explicitly set the shell type you know is correct,
   311  or disable shell access until you know.
   312  
   313  ### Checksum
   314  
   315  SFTP does not natively support checksums (file hash), but rclone
   316  is able to use checksumming if the same login has shell access,
   317  and can execute remote commands. If there is a command that can
   318  calculate compatible checksums on the remote system, Rclone can
   319  then be configured to execute this whenever a checksum is needed,
   320  and read back the results. Currently MD5 and SHA-1 are supported.
   321  
   322  Normally this requires an external utility being available on
   323  the server. By default rclone will try commands `md5sum`, `md5`
   324  and `rclone md5sum` for MD5 checksums, and the first one found usable
   325  will be picked. Same with `sha1sum`, `sha1` and `rclone sha1sum`
   326  commands for SHA-1 checksums. These utilities normally need to
   327  be in the remote's PATH to be found.
   328  
   329  In some cases the shell itself is capable of calculating checksums.
   330  PowerShell is an example of such a shell. If rclone detects that the
   331  remote shell is PowerShell, which means it most probably is a
   332  Windows OpenSSH server, rclone will use a predefined script block
   333  to produce the checksums when no external checksum commands are found
   334  (see [shell access](#shell-access)). This assumes PowerShell version
   335  4.0 or newer.
   336  
   337  The options `md5sum_command` and `sha1_command` can be used to customize
   338  the command to be executed for calculation of checksums. You can for
   339  example set a specific path to where md5sum and sha1sum executables
   340  are located, or use them to specify some other tools that print checksums
   341  in compatible format. The value can include command-line arguments,
   342  or even shell script blocks as with PowerShell. Rclone has subcommands
   343  [md5sum](/commands/rclone_md5sum/) and [sha1sum](/commands/rclone_sha1sum/)
   344  that use compatible format, which means if you have an rclone executable
   345  on the server it can be used. As mentioned above, they will be automatically
   346  picked up if found in PATH, but if not you can set something like
   347  `/path/to/rclone md5sum` as the value of option `md5sum_command` to
   348  make sure a specific executable is used.
   349  
   350  Remote checksumming is recommended and enabled by default. First time
   351  rclone is using a SFTP remote, if options `md5sum_command` or `sha1_command`
   352  are not set, it will check if any of the default commands for each of them,
   353  as described above, can be used. The result will be saved in the remote
   354  configuration, so next time it will use the same. Value `none`
   355  will be set if none of the default commands could be used for a specific
   356  algorithm, and this algorithm will not be supported by the remote.
   357  
   358  Disabling the checksumming may be required if you are connecting to SFTP servers
   359  which are not under your control, and to which the execution of remote shell
   360  commands is prohibited.  Set the configuration option `disable_hashcheck`
   361  to `true` to disable checksumming entirely, or set `shell_type` to `none`
   362  to disable all functionality based on remote shell command execution.
   363  
   364  ### Modification times and hashes
   365  
   366  Modified times are stored on the server to 1 second precision.
   367  
   368  Modified times are used in syncing and are fully supported.
   369  
   370  Some SFTP servers disable setting/modifying the file modification time after
   371  upload (for example, certain configurations of ProFTPd with mod_sftp). If you
   372  are using one of these servers, you can set the option `set_modtime = false` in
   373  your RClone backend configuration to disable this behaviour.
   374  
   375  ### About command
   376  
   377  The `about` command returns the total space, free space, and used
   378  space on the remote for the disk of the specified path on the remote or,
   379  if not set, the disk of the root on the remote.
   380  
   381  SFTP usually supports the [about](/commands/rclone_about/) command, but
   382  it depends on the server. If the server implements the vendor-specific
   383  VFS statistics extension, which is normally the case with OpenSSH instances,
   384  it will be used. If not, but the same login has access to a Unix shell,
   385  where the `df` command is available (e.g. in the remote's PATH), then
   386  this will be used instead. If the server shell is PowerShell, probably
   387  with a Windows OpenSSH server, rclone will use a built-in shell command
   388  (see [shell access](#shell-access)). If none of the above is applicable,
   389  `about` will fail.
   390  
   391  {{< rem autogenerated options start" - DO NOT EDIT - instead edit fs.RegInfo in backend/sftp/sftp.go then run make backenddocs" >}}
   392  ### Standard options
   393  
   394  Here are the Standard options specific to sftp (SSH/SFTP).
   395  
   396  #### --sftp-host
   397  
   398  SSH host to connect to.
   399  
   400  E.g. "example.com".
   401  
   402  Properties:
   403  
   404  - Config:      host
   405  - Env Var:     RCLONE_SFTP_HOST
   406  - Type:        string
   407  - Required:    true
   408  
   409  #### --sftp-user
   410  
   411  SSH username.
   412  
   413  Properties:
   414  
   415  - Config:      user
   416  - Env Var:     RCLONE_SFTP_USER
   417  - Type:        string
   418  - Default:     "$USER"
   419  
   420  #### --sftp-port
   421  
   422  SSH port number.
   423  
   424  Properties:
   425  
   426  - Config:      port
   427  - Env Var:     RCLONE_SFTP_PORT
   428  - Type:        int
   429  - Default:     22
   430  
   431  #### --sftp-pass
   432  
   433  SSH password, leave blank to use ssh-agent.
   434  
   435  **NB** Input to this must be obscured - see [rclone obscure](/commands/rclone_obscure/).
   436  
   437  Properties:
   438  
   439  - Config:      pass
   440  - Env Var:     RCLONE_SFTP_PASS
   441  - Type:        string
   442  - Required:    false
   443  
   444  #### --sftp-key-pem
   445  
   446  Raw PEM-encoded private key.
   447  
   448  If specified, will override key_file parameter.
   449  
   450  Properties:
   451  
   452  - Config:      key_pem
   453  - Env Var:     RCLONE_SFTP_KEY_PEM
   454  - Type:        string
   455  - Required:    false
   456  
   457  #### --sftp-key-file
   458  
   459  Path to PEM-encoded private key file.
   460  
   461  Leave blank or set key-use-agent to use ssh-agent.
   462  
   463  Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.
   464  
   465  Properties:
   466  
   467  - Config:      key_file
   468  - Env Var:     RCLONE_SFTP_KEY_FILE
   469  - Type:        string
   470  - Required:    false
   471  
   472  #### --sftp-key-file-pass
   473  
   474  The passphrase to decrypt the PEM-encoded private key file.
   475  
   476  Only PEM encrypted key files (old OpenSSH format) are supported. Encrypted keys
   477  in the new OpenSSH format can't be used.
   478  
   479  **NB** Input to this must be obscured - see [rclone obscure](/commands/rclone_obscure/).
   480  
   481  Properties:
   482  
   483  - Config:      key_file_pass
   484  - Env Var:     RCLONE_SFTP_KEY_FILE_PASS
   485  - Type:        string
   486  - Required:    false
   487  
   488  #### --sftp-pubkey-file
   489  
   490  Optional path to public key file.
   491  
   492  Set this if you have a signed certificate you want to use for authentication.
   493  
   494  Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.
   495  
   496  Properties:
   497  
   498  - Config:      pubkey_file
   499  - Env Var:     RCLONE_SFTP_PUBKEY_FILE
   500  - Type:        string
   501  - Required:    false
   502  
   503  #### --sftp-key-use-agent
   504  
   505  When set forces the usage of the ssh-agent.
   506  
   507  When key-file is also set, the ".pub" file of the specified key-file is read and only the associated key is
   508  requested from the ssh-agent. This allows to avoid `Too many authentication failures for *username*` errors
   509  when the ssh-agent contains many keys.
   510  
   511  Properties:
   512  
   513  - Config:      key_use_agent
   514  - Env Var:     RCLONE_SFTP_KEY_USE_AGENT
   515  - Type:        bool
   516  - Default:     false
   517  
   518  #### --sftp-use-insecure-cipher
   519  
   520  Enable the use of insecure ciphers and key exchange methods.
   521  
   522  This enables the use of the following insecure ciphers and key exchange methods:
   523  
   524  - aes128-cbc
   525  - aes192-cbc
   526  - aes256-cbc
   527  - 3des-cbc
   528  - diffie-hellman-group-exchange-sha256
   529  - diffie-hellman-group-exchange-sha1
   530  
   531  Those algorithms are insecure and may allow plaintext data to be recovered by an attacker.
   532  
   533  This must be false if you use either ciphers or key_exchange advanced options.
   534  
   535  
   536  Properties:
   537  
   538  - Config:      use_insecure_cipher
   539  - Env Var:     RCLONE_SFTP_USE_INSECURE_CIPHER
   540  - Type:        bool
   541  - Default:     false
   542  - Examples:
   543      - "false"
   544          - Use default Cipher list.
   545      - "true"
   546          - Enables the use of the aes128-cbc cipher and diffie-hellman-group-exchange-sha256, diffie-hellman-group-exchange-sha1 key exchange.
   547  
   548  #### --sftp-disable-hashcheck
   549  
   550  Disable the execution of SSH commands to determine if remote file hashing is available.
   551  
   552  Leave blank or set to false to enable hashing (recommended), set to true to disable hashing.
   553  
   554  Properties:
   555  
   556  - Config:      disable_hashcheck
   557  - Env Var:     RCLONE_SFTP_DISABLE_HASHCHECK
   558  - Type:        bool
   559  - Default:     false
   560  
   561  #### --sftp-ssh
   562  
   563  Path and arguments to external ssh binary.
   564  
   565  Normally rclone will use its internal ssh library to connect to the
   566  SFTP server. However it does not implement all possible ssh options so
   567  it may be desirable to use an external ssh binary.
   568  
   569  Rclone ignores all the internal config if you use this option and
   570  expects you to configure the ssh binary with the user/host/port and
   571  any other options you need.
   572  
   573  **Important** The ssh command must log in without asking for a
   574  password so needs to be configured with keys or certificates.
   575  
   576  Rclone will run the command supplied either with the additional
   577  arguments "-s sftp" to access the SFTP subsystem or with commands such
   578  as "md5sum /path/to/file" appended to read checksums.
   579  
   580  Any arguments with spaces in should be surrounded by "double quotes".
   581  
   582  An example setting might be:
   583  
   584      ssh -o ServerAliveInterval=20 user@example.com
   585  
   586  Note that when using an external ssh binary rclone makes a new ssh
   587  connection for every hash it calculates.
   588  
   589  
   590  Properties:
   591  
   592  - Config:      ssh
   593  - Env Var:     RCLONE_SFTP_SSH
   594  - Type:        SpaceSepList
   595  - Default:     
   596  
   597  ### Advanced options
   598  
   599  Here are the Advanced options specific to sftp (SSH/SFTP).
   600  
   601  #### --sftp-known-hosts-file
   602  
   603  Optional path to known_hosts file.
   604  
   605  Set this value to enable server host key validation.
   606  
   607  Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.
   608  
   609  Properties:
   610  
   611  - Config:      known_hosts_file
   612  - Env Var:     RCLONE_SFTP_KNOWN_HOSTS_FILE
   613  - Type:        string
   614  - Required:    false
   615  - Examples:
   616      - "~/.ssh/known_hosts"
   617          - Use OpenSSH's known_hosts file.
   618  
   619  #### --sftp-ask-password
   620  
   621  Allow asking for SFTP password when needed.
   622  
   623  If this is set and no password is supplied then rclone will:
   624  - ask for a password
   625  - not contact the ssh agent
   626  
   627  
   628  Properties:
   629  
   630  - Config:      ask_password
   631  - Env Var:     RCLONE_SFTP_ASK_PASSWORD
   632  - Type:        bool
   633  - Default:     false
   634  
   635  #### --sftp-path-override
   636  
   637  Override path used by SSH shell commands.
   638  
   639  This allows checksum calculation when SFTP and SSH paths are
   640  different. This issue affects among others Synology NAS boxes.
   641  
   642  E.g. if shared folders can be found in directories representing volumes:
   643  
   644      rclone sync /home/local/directory remote:/directory --sftp-path-override /volume2/directory
   645  
   646  E.g. if home directory can be found in a shared folder called "home":
   647  
   648      rclone sync /home/local/directory remote:/home/directory --sftp-path-override /volume1/homes/USER/directory
   649  	
   650  To specify only the path to the SFTP remote's root, and allow rclone to add any relative subpaths automatically (including unwrapping/decrypting remotes as necessary), add the '@' character to the beginning of the path.
   651  
   652  E.g. the first example above could be rewritten as:
   653  
   654  	rclone sync /home/local/directory remote:/directory --sftp-path-override @/volume2
   655  	
   656  Note that when using this method with Synology "home" folders, the full "/homes/USER" path should be specified instead of "/home".
   657  
   658  E.g. the second example above should be rewritten as:
   659  
   660  	rclone sync /home/local/directory remote:/homes/USER/directory --sftp-path-override @/volume1
   661  
   662  Properties:
   663  
   664  - Config:      path_override
   665  - Env Var:     RCLONE_SFTP_PATH_OVERRIDE
   666  - Type:        string
   667  - Required:    false
   668  
   669  #### --sftp-set-modtime
   670  
   671  Set the modified time on the remote if set.
   672  
   673  Properties:
   674  
   675  - Config:      set_modtime
   676  - Env Var:     RCLONE_SFTP_SET_MODTIME
   677  - Type:        bool
   678  - Default:     true
   679  
   680  #### --sftp-shell-type
   681  
   682  The type of SSH shell on remote server, if any.
   683  
   684  Leave blank for autodetect.
   685  
   686  Properties:
   687  
   688  - Config:      shell_type
   689  - Env Var:     RCLONE_SFTP_SHELL_TYPE
   690  - Type:        string
   691  - Required:    false
   692  - Examples:
   693      - "none"
   694          - No shell access
   695      - "unix"
   696          - Unix shell
   697      - "powershell"
   698          - PowerShell
   699      - "cmd"
   700          - Windows Command Prompt
   701  
   702  #### --sftp-md5sum-command
   703  
   704  The command used to read md5 hashes.
   705  
   706  Leave blank for autodetect.
   707  
   708  Properties:
   709  
   710  - Config:      md5sum_command
   711  - Env Var:     RCLONE_SFTP_MD5SUM_COMMAND
   712  - Type:        string
   713  - Required:    false
   714  
   715  #### --sftp-sha1sum-command
   716  
   717  The command used to read sha1 hashes.
   718  
   719  Leave blank for autodetect.
   720  
   721  Properties:
   722  
   723  - Config:      sha1sum_command
   724  - Env Var:     RCLONE_SFTP_SHA1SUM_COMMAND
   725  - Type:        string
   726  - Required:    false
   727  
   728  #### --sftp-skip-links
   729  
   730  Set to skip any symlinks and any other non regular files.
   731  
   732  Properties:
   733  
   734  - Config:      skip_links
   735  - Env Var:     RCLONE_SFTP_SKIP_LINKS
   736  - Type:        bool
   737  - Default:     false
   738  
   739  #### --sftp-subsystem
   740  
   741  Specifies the SSH2 subsystem on the remote host.
   742  
   743  Properties:
   744  
   745  - Config:      subsystem
   746  - Env Var:     RCLONE_SFTP_SUBSYSTEM
   747  - Type:        string
   748  - Default:     "sftp"
   749  
   750  #### --sftp-server-command
   751  
   752  Specifies the path or command to run a sftp server on the remote host.
   753  
   754  The subsystem option is ignored when server_command is defined.
   755  
   756  If adding server_command to the configuration file please note that 
   757  it should not be enclosed in quotes, since that will make rclone fail.
   758  
   759  A working example is:
   760  
   761      [remote_name]
   762      type = sftp
   763      server_command = sudo /usr/libexec/openssh/sftp-server
   764  
   765  Properties:
   766  
   767  - Config:      server_command
   768  - Env Var:     RCLONE_SFTP_SERVER_COMMAND
   769  - Type:        string
   770  - Required:    false
   771  
   772  #### --sftp-use-fstat
   773  
   774  If set use fstat instead of stat.
   775  
   776  Some servers limit the amount of open files and calling Stat after opening
   777  the file will throw an error from the server. Setting this flag will call
   778  Fstat instead of Stat which is called on an already open file handle.
   779  
   780  It has been found that this helps with IBM Sterling SFTP servers which have
   781  "extractability" level set to 1 which means only 1 file can be opened at
   782  any given time.
   783  
   784  
   785  Properties:
   786  
   787  - Config:      use_fstat
   788  - Env Var:     RCLONE_SFTP_USE_FSTAT
   789  - Type:        bool
   790  - Default:     false
   791  
   792  #### --sftp-disable-concurrent-reads
   793  
   794  If set don't use concurrent reads.
   795  
   796  Normally concurrent reads are safe to use and not using them will
   797  degrade performance, so this option is disabled by default.
   798  
   799  Some servers limit the amount number of times a file can be
   800  downloaded. Using concurrent reads can trigger this limit, so if you
   801  have a server which returns
   802  
   803      Failed to copy: file does not exist
   804  
   805  Then you may need to enable this flag.
   806  
   807  If concurrent reads are disabled, the use_fstat option is ignored.
   808  
   809  
   810  Properties:
   811  
   812  - Config:      disable_concurrent_reads
   813  - Env Var:     RCLONE_SFTP_DISABLE_CONCURRENT_READS
   814  - Type:        bool
   815  - Default:     false
   816  
   817  #### --sftp-disable-concurrent-writes
   818  
   819  If set don't use concurrent writes.
   820  
   821  Normally rclone uses concurrent writes to upload files. This improves
   822  the performance greatly, especially for distant servers.
   823  
   824  This option disables concurrent writes should that be necessary.
   825  
   826  
   827  Properties:
   828  
   829  - Config:      disable_concurrent_writes
   830  - Env Var:     RCLONE_SFTP_DISABLE_CONCURRENT_WRITES
   831  - Type:        bool
   832  - Default:     false
   833  
   834  #### --sftp-idle-timeout
   835  
   836  Max time before closing idle connections.
   837  
   838  If no connections have been returned to the connection pool in the time
   839  given, rclone will empty the connection pool.
   840  
   841  Set to 0 to keep connections indefinitely.
   842  
   843  
   844  Properties:
   845  
   846  - Config:      idle_timeout
   847  - Env Var:     RCLONE_SFTP_IDLE_TIMEOUT
   848  - Type:        Duration
   849  - Default:     1m0s
   850  
   851  #### --sftp-chunk-size
   852  
   853  Upload and download chunk size.
   854  
   855  This controls the maximum size of payload in SFTP protocol packets.
   856  The RFC limits this to 32768 bytes (32k), which is the default. However,
   857  a lot of servers support larger sizes, typically limited to a maximum
   858  total package size of 256k, and setting it larger will increase transfer
   859  speed dramatically on high latency links. This includes OpenSSH, and,
   860  for example, using the value of 255k works well, leaving plenty of room
   861  for overhead while still being within a total packet size of 256k.
   862  
   863  Make sure to test thoroughly before using a value higher than 32k,
   864  and only use it if you always connect to the same server or after
   865  sufficiently broad testing. If you get errors such as
   866  "failed to send packet payload: EOF", lots of "connection lost",
   867  or "corrupted on transfer", when copying a larger file, try lowering
   868  the value. The server run by [rclone serve sftp](/commands/rclone_serve_sftp)
   869  sends packets with standard 32k maximum payload so you must not
   870  set a different chunk_size when downloading files, but it accepts
   871  packets up to the 256k total size, so for uploads the chunk_size
   872  can be set as for the OpenSSH example above.
   873  
   874  
   875  Properties:
   876  
   877  - Config:      chunk_size
   878  - Env Var:     RCLONE_SFTP_CHUNK_SIZE
   879  - Type:        SizeSuffix
   880  - Default:     32Ki
   881  
   882  #### --sftp-concurrency
   883  
   884  The maximum number of outstanding requests for one file
   885  
   886  This controls the maximum number of outstanding requests for one file.
   887  Increasing it will increase throughput on high latency links at the
   888  cost of using more memory.
   889  
   890  
   891  Properties:
   892  
   893  - Config:      concurrency
   894  - Env Var:     RCLONE_SFTP_CONCURRENCY
   895  - Type:        int
   896  - Default:     64
   897  
   898  #### --sftp-set-env
   899  
   900  Environment variables to pass to sftp and commands
   901  
   902  Set environment variables in the form:
   903  
   904      VAR=value
   905  
   906  to be passed to the sftp client and to any commands run (eg md5sum).
   907  
   908  Pass multiple variables space separated, eg
   909  
   910      VAR1=value VAR2=value
   911  
   912  and pass variables with spaces in quotes, eg
   913  
   914      "VAR3=value with space" "VAR4=value with space" VAR5=nospacehere
   915  
   916  
   917  
   918  Properties:
   919  
   920  - Config:      set_env
   921  - Env Var:     RCLONE_SFTP_SET_ENV
   922  - Type:        SpaceSepList
   923  - Default:     
   924  
   925  #### --sftp-ciphers
   926  
   927  Space separated list of ciphers to be used for session encryption, ordered by preference.
   928  
   929  At least one must match with server configuration. This can be checked for example using ssh -Q cipher.
   930  
   931  This must not be set if use_insecure_cipher is true.
   932  
   933  Example:
   934  
   935      aes128-ctr aes192-ctr aes256-ctr aes128-gcm@openssh.com aes256-gcm@openssh.com
   936  
   937  
   938  Properties:
   939  
   940  - Config:      ciphers
   941  - Env Var:     RCLONE_SFTP_CIPHERS
   942  - Type:        SpaceSepList
   943  - Default:     
   944  
   945  #### --sftp-key-exchange
   946  
   947  Space separated list of key exchange algorithms, ordered by preference.
   948  
   949  At least one must match with server configuration. This can be checked for example using ssh -Q kex.
   950  
   951  This must not be set if use_insecure_cipher is true.
   952  
   953  Example:
   954  
   955      sntrup761x25519-sha512@openssh.com curve25519-sha256 curve25519-sha256@libssh.org ecdh-sha2-nistp256
   956  
   957  
   958  Properties:
   959  
   960  - Config:      key_exchange
   961  - Env Var:     RCLONE_SFTP_KEY_EXCHANGE
   962  - Type:        SpaceSepList
   963  - Default:     
   964  
   965  #### --sftp-macs
   966  
   967  Space separated list of MACs (message authentication code) algorithms, ordered by preference.
   968  
   969  At least one must match with server configuration. This can be checked for example using ssh -Q mac.
   970  
   971  Example:
   972  
   973      umac-64-etm@openssh.com umac-128-etm@openssh.com hmac-sha2-256-etm@openssh.com
   974  
   975  
   976  Properties:
   977  
   978  - Config:      macs
   979  - Env Var:     RCLONE_SFTP_MACS
   980  - Type:        SpaceSepList
   981  - Default:     
   982  
   983  #### --sftp-host-key-algorithms
   984  
   985  Space separated list of host key algorithms, ordered by preference.
   986  
   987  At least one must match with server configuration. This can be checked for example using ssh -Q HostKeyAlgorithms.
   988  
   989  Note: This can affect the outcome of key negotiation with the server even if server host key validation is not enabled.
   990  
   991  Example:
   992  
   993      ssh-ed25519 ssh-rsa ssh-dss
   994  
   995  
   996  Properties:
   997  
   998  - Config:      host_key_algorithms
   999  - Env Var:     RCLONE_SFTP_HOST_KEY_ALGORITHMS
  1000  - Type:        SpaceSepList
  1001  - Default:     
  1002  
  1003  #### --sftp-socks-proxy
  1004  
  1005  Socks 5 proxy host.
  1006  	
  1007  Supports the format user:pass@host:port, user@host:port, host:port.
  1008  
  1009  Example:
  1010  
  1011  	myUser:myPass@localhost:9005
  1012  	
  1013  
  1014  Properties:
  1015  
  1016  - Config:      socks_proxy
  1017  - Env Var:     RCLONE_SFTP_SOCKS_PROXY
  1018  - Type:        string
  1019  - Required:    false
  1020  
  1021  #### --sftp-copy-is-hardlink
  1022  
  1023  Set to enable server side copies using hardlinks.
  1024  
  1025  The SFTP protocol does not define a copy command so normally server
  1026  side copies are not allowed with the sftp backend.
  1027  
  1028  However the SFTP protocol does support hardlinking, and if you enable
  1029  this flag then the sftp backend will support server side copies. These
  1030  will be implemented by doing a hardlink from the source to the
  1031  destination.
  1032  
  1033  Not all sftp servers support this.
  1034  
  1035  Note that hardlinking two files together will use no additional space
  1036  as the source and the destination will be the same file.
  1037  
  1038  This feature may be useful backups made with --copy-dest.
  1039  
  1040  Properties:
  1041  
  1042  - Config:      copy_is_hardlink
  1043  - Env Var:     RCLONE_SFTP_COPY_IS_HARDLINK
  1044  - Type:        bool
  1045  - Default:     false
  1046  
  1047  #### --sftp-description
  1048  
  1049  Description of the remote
  1050  
  1051  Properties:
  1052  
  1053  - Config:      description
  1054  - Env Var:     RCLONE_SFTP_DESCRIPTION
  1055  - Type:        string
  1056  - Required:    false
  1057  
  1058  {{< rem autogenerated options stop >}}
  1059  
  1060  ## Limitations
  1061  
  1062  On some SFTP servers (e.g. Synology) the paths are different
  1063  for SSH and SFTP so the hashes can't be calculated properly.
  1064  For them using `disable_hashcheck` is a good idea.
  1065  
  1066  The only ssh agent supported under Windows is Putty's pageant.
  1067  
  1068  The Go SSH library disables the use of the aes128-cbc cipher by
  1069  default, due to security concerns. This can be re-enabled on a
  1070  per-connection basis by setting the `use_insecure_cipher` setting in
  1071  the configuration file to `true`. Further details on the insecurity of
  1072  this cipher can be found
  1073  [in this paper](http://www.isg.rhul.ac.uk/~kp/SandPfinal.pdf).
  1074  
  1075  SFTP isn't supported under plan9 until [this
  1076  issue](https://github.com/pkg/sftp/issues/156) is fixed.
  1077  
  1078  Note that since SFTP isn't HTTP based the following flags don't work
  1079  with it: `--dump-headers`, `--dump-bodies`, `--dump-auth`.
  1080  
  1081  Note that `--timeout` and `--contimeout` are both supported.
  1082  
  1083  ## rsync.net {#rsync-net}
  1084  
  1085  rsync.net is supported through the SFTP backend.
  1086  
  1087  See [rsync.net's documentation of rclone examples](https://www.rsync.net/products/rclone.html).
  1088  
  1089  ## Hetzner Storage Box {#hetzner-storage-box}
  1090  
  1091  Hetzner Storage Boxes are supported through the SFTP backend on port 23.
  1092  
  1093  See [Hetzner's documentation for details](https://docs.hetzner.com/robot/storage-box/access/access-ssh-rsync-borg#rclone)