github.com/10XDev/rclone@v1.52.3-0.20200626220027-16af9ab76b2a/docs/content/sftp.md (about) 1 --- 2 title: "SFTP" 3 description: "SFTP" 4 --- 5 6 {{< icon "fa fa-server" >}} SFTP 7 ---------------------------------------- 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="C14" home="https://www.online.net/en/storage/c14-cold-storage" config="/sftp/#c14">}} 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. 25 26 "Note that some SFTP servers will need the leading / - Synology is a 27 good example of this. rsync.net, on the other hand, requires users to 28 OMIT the leading /. 29 30 Here is an example of making an SFTP configuration. First run 31 32 rclone config 33 34 This will guide you through an interactive setup process. 35 36 ``` 37 No remotes found - make a new one 38 n) New remote 39 s) Set configuration password 40 q) Quit config 41 n/s/q> n 42 name> remote 43 Type of storage to configure. 44 Choose a number from below, or type in your own value 45 [snip] 46 XX / SSH/SFTP Connection 47 \ "sftp" 48 [snip] 49 Storage> sftp 50 SSH host to connect to 51 Choose a number from below, or type in your own value 52 1 / Connect to example.com 53 \ "example.com" 54 host> example.com 55 SSH username, leave blank for current username, ncw 56 user> sftpuser 57 SSH port, leave blank to use default (22) 58 port> 59 SSH password, leave blank to use ssh-agent. 60 y) Yes type in my own password 61 g) Generate random password 62 n) No leave this optional password blank 63 y/g/n> n 64 Path to unencrypted PEM-encoded private key file, leave blank to use ssh-agent. 65 key_file> 66 Remote config 67 -------------------- 68 [remote] 69 host = example.com 70 user = sftpuser 71 port = 72 pass = 73 key_file = 74 -------------------- 75 y) Yes this is OK 76 e) Edit this remote 77 d) Delete this remote 78 y/e/d> y 79 ``` 80 81 This remote is called `remote` and can now be used like this: 82 83 See all directories in the home directory 84 85 rclone lsd remote: 86 87 Make a new directory 88 89 rclone mkdir remote:path/to/directory 90 91 List the contents of a directory 92 93 rclone ls remote:path/to/directory 94 95 Sync `/home/local/directory` to the remote directory, deleting any 96 excess files in the directory. 97 98 rclone sync /home/local/directory remote:directory 99 100 ### SSH Authentication ### 101 102 The SFTP remote supports three authentication methods: 103 104 * Password 105 * Key file 106 * ssh-agent 107 108 Key files should be PEM-encoded private key files. For instance `/home/$USER/.ssh/id_rsa`. 109 Only unencrypted OpenSSH or PEM encrypted files are supported. 110 111 The key file can be specified in either an external file (key_file) or contained within the 112 rclone config file (key_pem). If using key_pem in the config file, the entry should be on a 113 single line with new line ('\n' or '\r\n') separating lines. i.e. 114 115 key_pem = -----BEGIN RSA PRIVATE KEY-----\nMaMbaIXtE\n0gAMbMbaSsd\nMbaass\n-----END RSA PRIVATE KEY----- 116 117 This will generate it correctly for key_pem for use in the config: 118 119 awk '{printf "%s\\n", $0}' < ~/.ssh/id_rsa 120 121 If you don't specify `pass`, `key_file`, or `key_pem` then rclone will attempt to contact an ssh-agent. 122 123 You can also specify `key_use_agent` to force the usage of an ssh-agent. In this case 124 `key_file` or `key_pem` can also be specified to force the usage of a specific key in the ssh-agent. 125 126 Using an ssh-agent is the only way to load encrypted OpenSSH keys at the moment. 127 128 If you set the `--sftp-ask-password` option, rclone will prompt for a 129 password when needed and no password has been configured. 130 131 ### ssh-agent on macOS ### 132 133 Note that there seem to be various problems with using an ssh-agent on 134 macOS due to recent changes in the OS. The most effective work-around 135 seems to be to start an ssh-agent in each session, eg 136 137 eval `ssh-agent -s` && ssh-add -A 138 139 And then at the end of the session 140 141 eval `ssh-agent -k` 142 143 These commands can be used in scripts of course. 144 145 ### Modified time ### 146 147 Modified times are stored on the server to 1 second precision. 148 149 Modified times are used in syncing and are fully supported. 150 151 Some SFTP servers disable setting/modifying the file modification time after 152 upload (for example, certain configurations of ProFTPd with mod_sftp). If you 153 are using one of these servers, you can set the option `set_modtime = false` in 154 your RClone backend configuration to disable this behaviour. 155 156 {{< rem autogenerated options start" - DO NOT EDIT - instead edit fs.RegInfo in backend/sftp/sftp.go then run make backenddocs" >}} 157 ### Standard Options 158 159 Here are the standard options specific to sftp (SSH/SFTP Connection). 160 161 #### --sftp-host 162 163 SSH host to connect to 164 165 - Config: host 166 - Env Var: RCLONE_SFTP_HOST 167 - Type: string 168 - Default: "" 169 - Examples: 170 - "example.com" 171 - Connect to example.com 172 173 #### --sftp-user 174 175 SSH username, leave blank for current username, ncw 176 177 - Config: user 178 - Env Var: RCLONE_SFTP_USER 179 - Type: string 180 - Default: "" 181 182 #### --sftp-port 183 184 SSH port, leave blank to use default (22) 185 186 - Config: port 187 - Env Var: RCLONE_SFTP_PORT 188 - Type: string 189 - Default: "" 190 191 #### --sftp-pass 192 193 SSH password, leave blank to use ssh-agent. 194 195 **NB** Input to this must be obscured - see [rclone obscure](/commands/rclone_obscure/). 196 197 - Config: pass 198 - Env Var: RCLONE_SFTP_PASS 199 - Type: string 200 - Default: "" 201 202 #### --sftp-key-pem 203 204 Raw PEM-encoded private key, If specified, will override key_file parameter. 205 206 - Config: key_pem 207 - Env Var: RCLONE_SFTP_KEY_PEM 208 - Type: string 209 - Default: "" 210 211 #### --sftp-key-file 212 213 Path to PEM-encoded private key file, leave blank or set key-use-agent to use ssh-agent. 214 215 - Config: key_file 216 - Env Var: RCLONE_SFTP_KEY_FILE 217 - Type: string 218 - Default: "" 219 220 #### --sftp-key-file-pass 221 222 The passphrase to decrypt the PEM-encoded private key file. 223 224 Only PEM encrypted key files (old OpenSSH format) are supported. Encrypted keys 225 in the new OpenSSH format can't be used. 226 227 **NB** Input to this must be obscured - see [rclone obscure](/commands/rclone_obscure/). 228 229 - Config: key_file_pass 230 - Env Var: RCLONE_SFTP_KEY_FILE_PASS 231 - Type: string 232 - Default: "" 233 234 #### --sftp-key-use-agent 235 236 When set forces the usage of the ssh-agent. 237 238 When key-file is also set, the ".pub" file of the specified key-file is read and only the associated key is 239 requested from the ssh-agent. This allows to avoid `Too many authentication failures for *username*` errors 240 when the ssh-agent contains many keys. 241 242 - Config: key_use_agent 243 - Env Var: RCLONE_SFTP_KEY_USE_AGENT 244 - Type: bool 245 - Default: false 246 247 #### --sftp-use-insecure-cipher 248 249 Enable the use of insecure ciphers and key exchange methods. 250 251 This enables the use of the following insecure ciphers and key exchange methods: 252 253 - aes128-cbc 254 - aes192-cbc 255 - aes256-cbc 256 - 3des-cbc 257 - diffie-hellman-group-exchange-sha256 258 - diffie-hellman-group-exchange-sha1 259 260 Those algorithms are insecure and may allow plaintext data to be recovered by an attacker. 261 262 - Config: use_insecure_cipher 263 - Env Var: RCLONE_SFTP_USE_INSECURE_CIPHER 264 - Type: bool 265 - Default: false 266 - Examples: 267 - "false" 268 - Use default Cipher list. 269 - "true" 270 - Enables the use of the aes128-cbc cipher and diffie-hellman-group-exchange-sha256, diffie-hellman-group-exchange-sha1 key exchange. 271 272 #### --sftp-disable-hashcheck 273 274 Disable the execution of SSH commands to determine if remote file hashing is available. 275 Leave blank or set to false to enable hashing (recommended), set to true to disable hashing. 276 277 - Config: disable_hashcheck 278 - Env Var: RCLONE_SFTP_DISABLE_HASHCHECK 279 - Type: bool 280 - Default: false 281 282 ### Advanced Options 283 284 Here are the advanced options specific to sftp (SSH/SFTP Connection). 285 286 #### --sftp-ask-password 287 288 Allow asking for SFTP password when needed. 289 290 If this is set and no password is supplied then rclone will: 291 - ask for a password 292 - not contact the ssh agent 293 294 295 - Config: ask_password 296 - Env Var: RCLONE_SFTP_ASK_PASSWORD 297 - Type: bool 298 - Default: false 299 300 #### --sftp-path-override 301 302 Override path used by SSH connection. 303 304 This allows checksum calculation when SFTP and SSH paths are 305 different. This issue affects among others Synology NAS boxes. 306 307 Shared folders can be found in directories representing volumes 308 309 rclone sync /home/local/directory remote:/directory --ssh-path-override /volume2/directory 310 311 Home directory can be found in a shared folder called "home" 312 313 rclone sync /home/local/directory remote:/home/directory --ssh-path-override /volume1/homes/USER/directory 314 315 - Config: path_override 316 - Env Var: RCLONE_SFTP_PATH_OVERRIDE 317 - Type: string 318 - Default: "" 319 320 #### --sftp-set-modtime 321 322 Set the modified time on the remote if set. 323 324 - Config: set_modtime 325 - Env Var: RCLONE_SFTP_SET_MODTIME 326 - Type: bool 327 - Default: true 328 329 #### --sftp-md5sum-command 330 331 The command used to read md5 hashes. Leave blank for autodetect. 332 333 - Config: md5sum_command 334 - Env Var: RCLONE_SFTP_MD5SUM_COMMAND 335 - Type: string 336 - Default: "" 337 338 #### --sftp-sha1sum-command 339 340 The command used to read sha1 hashes. Leave blank for autodetect. 341 342 - Config: sha1sum_command 343 - Env Var: RCLONE_SFTP_SHA1SUM_COMMAND 344 - Type: string 345 - Default: "" 346 347 #### --sftp-skip-links 348 349 Set to skip any symlinks and any other non regular files. 350 351 - Config: skip_links 352 - Env Var: RCLONE_SFTP_SKIP_LINKS 353 - Type: bool 354 - Default: false 355 356 {{< rem autogenerated options stop >}} 357 358 ### Limitations ### 359 360 SFTP supports checksums if the same login has shell access and `md5sum` 361 or `sha1sum` as well as `echo` are in the remote's PATH. 362 This remote checksumming (file hashing) is recommended and enabled by default. 363 Disabling the checksumming may be required if you are connecting to SFTP servers 364 which are not under your control, and to which the execution of remote commands 365 is prohibited. Set the configuration option `disable_hashcheck` to `true` to 366 disable checksumming. 367 368 SFTP also supports `about` if the same login has shell 369 access and `df` are in the remote's PATH. `about` will 370 return the total space, free space, and used space on the remote 371 for the disk of the specified path on the remote or, if not set, 372 the disk of the root on the remote. 373 `about` will fail if it does not have shell 374 access or if `df` is not in the remote's PATH. 375 376 Note that some SFTP servers (eg Synology) the paths are different for 377 SSH and SFTP so the hashes can't be calculated properly. For them 378 using `disable_hashcheck` is a good idea. 379 380 The only ssh agent supported under Windows is Putty's pageant. 381 382 The Go SSH library disables the use of the aes128-cbc cipher by 383 default, due to security concerns. This can be re-enabled on a 384 per-connection basis by setting the `use_insecure_cipher` setting in 385 the configuration file to `true`. Further details on the insecurity of 386 this cipher can be found [in this paper] 387 (http://www.isg.rhul.ac.uk/~kp/SandPfinal.pdf). 388 389 SFTP isn't supported under plan9 until [this 390 issue](https://github.com/pkg/sftp/issues/156) is fixed. 391 392 Note that since SFTP isn't HTTP based the following flags don't work 393 with it: `--dump-headers`, `--dump-bodies`, `--dump-auth` 394 395 Note that `--timeout` isn't supported (but `--contimeout` is). 396 397 398 ## C14 {#c14} 399 400 C14 is supported through the SFTP backend. 401 402 See [C14's documentation](https://www.online.net/en/storage/c14-cold-storage) 403 404 ## rsync.net {#rsync-net} 405 406 rsync.net is supported through the SFTP backend. 407 408 See [rsync.net's documentation of rclone examples](https://www.rsync.net/products/rclone.html).