github.com/10XDev/rclone@v1.52.3-0.20200626220027-16af9ab76b2a/docs/content/commands/rclone_serve_ftp.md (about) 1 --- 2 title: "rclone serve ftp" 3 description: "Serve remote:path over FTP." 4 slug: rclone_serve_ftp 5 url: /commands/rclone_serve_ftp/ 6 # autogenerated - DO NOT EDIT, instead edit the source code in cmd/serve/ftp/ and as part of making a release run "make commanddocs" 7 --- 8 # rclone serve ftp 9 10 Serve remote:path over FTP. 11 12 ## Synopsis 13 14 15 rclone serve ftp implements a basic ftp server to serve the 16 remote over FTP protocol. This can be viewed with a ftp client 17 or you can make a remote of type ftp to read and write it. 18 19 ## Server options 20 21 Use --addr to specify which IP address and port the server should 22 listen on, eg --addr 1.2.3.4:8000 or --addr :8080 to listen to all 23 IPs. By default it only listens on localhost. You can use port 24 :0 to let the OS choose an available port. 25 26 If you set --addr to listen on a public or LAN accessible IP address 27 then using Authentication is advised - see the next section for info. 28 29 ### Authentication 30 31 By default this will serve files without needing a login. 32 33 You can set a single username and password with the --user and --pass flags. 34 35 ## Directory Cache 36 37 Using the `--dir-cache-time` flag, you can set how long a 38 directory should be considered up to date and not refreshed from the 39 backend. Changes made locally in the mount may appear immediately or 40 invalidate the cache. However, changes done on the remote will only 41 be picked up once the cache expires if the backend configured does not 42 support polling for changes. If the backend supports polling, changes 43 will be picked up on within the polling interval. 44 45 Alternatively, you can send a `SIGHUP` signal to rclone for 46 it to flush all directory caches, regardless of how old they are. 47 Assuming only one rclone instance is running, you can reset the cache 48 like this: 49 50 kill -SIGHUP $(pidof rclone) 51 52 If you configure rclone with a [remote control](/rc) then you can use 53 rclone rc to flush the whole directory cache: 54 55 rclone rc vfs/forget 56 57 Or individual files or directories: 58 59 rclone rc vfs/forget file=path/to/file dir=path/to/dir 60 61 ## File Buffering 62 63 The `--buffer-size` flag determines the amount of memory, 64 that will be used to buffer data in advance. 65 66 Each open file descriptor will try to keep the specified amount of 67 data in memory at all times. The buffered data is bound to one file 68 descriptor and won't be shared between multiple open file descriptors 69 of the same file. 70 71 This flag is a upper limit for the used memory per file descriptor. 72 The buffer will only use memory for data that is downloaded but not 73 not yet read. If the buffer is empty, only a small amount of memory 74 will be used. 75 The maximum memory used by rclone for buffering can be up to 76 `--buffer-size * open files`. 77 78 ## File Caching 79 80 These flags control the VFS file caching options. The VFS layer is 81 used by rclone mount to make a cloud storage system work more like a 82 normal file system. 83 84 You'll need to enable VFS caching if you want, for example, to read 85 and write simultaneously to a file. See below for more details. 86 87 Note that the VFS cache works in addition to the cache backend and you 88 may find that you need one or the other or both. 89 90 --cache-dir string Directory rclone will use for caching. 91 --vfs-cache-max-age duration Max age of objects in the cache. (default 1h0m0s) 92 --vfs-cache-mode string Cache mode off|minimal|writes|full (default "off") 93 --vfs-cache-poll-interval duration Interval to poll the cache for stale objects. (default 1m0s) 94 --vfs-cache-max-size int Max total size of objects in the cache. (default off) 95 96 If run with `-vv` rclone will print the location of the file cache. The 97 files are stored in the user cache file area which is OS dependent but 98 can be controlled with `--cache-dir` or setting the appropriate 99 environment variable. 100 101 The cache has 4 different modes selected by `--vfs-cache-mode`. 102 The higher the cache mode the more compatible rclone becomes at the 103 cost of using disk space. 104 105 Note that files are written back to the remote only when they are 106 closed so if rclone is quit or dies with open files then these won't 107 get written back to the remote. However they will still be in the on 108 disk cache. 109 110 If using --vfs-cache-max-size note that the cache may exceed this size 111 for two reasons. Firstly because it is only checked every 112 --vfs-cache-poll-interval. Secondly because open files cannot be 113 evicted from the cache. 114 115 ### --vfs-cache-mode off 116 117 In this mode the cache will read directly from the remote and write 118 directly to the remote without caching anything on disk. 119 120 This will mean some operations are not possible 121 122 * Files can't be opened for both read AND write 123 * Files opened for write can't be seeked 124 * Existing files opened for write must have O_TRUNC set 125 * Files open for read with O_TRUNC will be opened write only 126 * Files open for write only will behave as if O_TRUNC was supplied 127 * Open modes O_APPEND, O_TRUNC are ignored 128 * If an upload fails it can't be retried 129 130 ### --vfs-cache-mode minimal 131 132 This is very similar to "off" except that files opened for read AND 133 write will be buffered to disks. This means that files opened for 134 write will be a lot more compatible, but uses the minimal disk space. 135 136 These operations are not possible 137 138 * Files opened for write only can't be seeked 139 * Existing files opened for write must have O_TRUNC set 140 * Files opened for write only will ignore O_APPEND, O_TRUNC 141 * If an upload fails it can't be retried 142 143 ### --vfs-cache-mode writes 144 145 In this mode files opened for read only are still read directly from 146 the remote, write only and read/write files are buffered to disk 147 first. 148 149 This mode should support all normal file system operations. 150 151 If an upload fails it will be retried up to --low-level-retries times. 152 153 ### --vfs-cache-mode full 154 155 In this mode all reads and writes are buffered to and from disk. When 156 a file is opened for read it will be downloaded in its entirety first. 157 158 This may be appropriate for your needs, or you may prefer to look at 159 the cache backend which does a much more sophisticated job of caching, 160 including caching directory hierarchies and chunks of files. 161 162 In this mode, unlike the others, when a file is written to the disk, 163 it will be kept on the disk after it is written to the remote. It 164 will be purged on a schedule according to `--vfs-cache-max-age`. 165 166 This mode should support all normal file system operations. 167 168 If an upload or download fails it will be retried up to 169 --low-level-retries times. 170 171 ## Case Sensitivity 172 173 Linux file systems are case-sensitive: two files can differ only 174 by case, and the exact case must be used when opening a file. 175 176 Windows is not like most other operating systems supported by rclone. 177 File systems in modern Windows are case-insensitive but case-preserving: 178 although existing files can be opened using any case, the exact case used 179 to create the file is preserved and available for programs to query. 180 It is not allowed for two files in the same directory to differ only by case. 181 182 Usually file systems on macOS are case-insensitive. It is possible to make macOS 183 file systems case-sensitive but that is not the default 184 185 The "--vfs-case-insensitive" mount flag controls how rclone handles these 186 two cases. If its value is "false", rclone passes file names to the mounted 187 file system as is. If the flag is "true" (or appears without a value on 188 command line), rclone may perform a "fixup" as explained below. 189 190 The user may specify a file name to open/delete/rename/etc with a case 191 different than what is stored on mounted file system. If an argument refers 192 to an existing file with exactly the same name, then the case of the existing 193 file on the disk will be used. However, if a file name with exactly the same 194 name is not found but a name differing only by case exists, rclone will 195 transparently fixup the name. This fixup happens only when an existing file 196 is requested. Case sensitivity of file names created anew by rclone is 197 controlled by an underlying mounted file system. 198 199 Note that case sensitivity of the operating system running rclone (the target) 200 may differ from case sensitivity of a file system mounted by rclone (the source). 201 The flag controls whether "fixup" is performed to satisfy the target. 202 203 If the flag is not provided on command line, then its default value depends 204 on the operating system where rclone runs: "true" on Windows and macOS, "false" 205 otherwise. If the flag is provided without a value, then it is "true". 206 207 ## Auth Proxy 208 209 If you supply the parameter `--auth-proxy /path/to/program` then 210 rclone will use that program to generate backends on the fly which 211 then are used to authenticate incoming requests. This uses a simple 212 JSON based protocl with input on STDIN and output on STDOUT. 213 214 **PLEASE NOTE:** `--auth-proxy` and `--authorized-keys` cannot be used 215 together, if `--auth-proxy` is set the authorized keys option will be 216 ignored. 217 218 There is an example program 219 [bin/test_proxy.py](https://github.com/rclone/rclone/blob/master/test_proxy.py) 220 in the rclone source code. 221 222 The program's job is to take a `user` and `pass` on the input and turn 223 those into the config for a backend on STDOUT in JSON format. This 224 config will have any default parameters for the backend added, but it 225 won't use configuration from environment variables or command line 226 options - it is the job of the proxy program to make a complete 227 config. 228 229 This config generated must have this extra parameter 230 - `_root` - root to use for the backend 231 232 And it may have this parameter 233 - `_obscure` - comma separated strings for parameters to obscure 234 235 If password authentication was used by the client, input to the proxy 236 process (on STDIN) would look similar to this: 237 238 ``` 239 { 240 "user": "me", 241 "pass": "mypassword" 242 } 243 ``` 244 245 If public-key authentication was used by the client, input to the 246 proxy process (on STDIN) would look similar to this: 247 248 ``` 249 { 250 "user": "me", 251 "public_key": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDuwESFdAe14hVS6omeyX7edc...JQdf" 252 } 253 ``` 254 255 And as an example return this on STDOUT 256 257 ``` 258 { 259 "type": "sftp", 260 "_root": "", 261 "_obscure": "pass", 262 "user": "me", 263 "pass": "mypassword", 264 "host": "sftp.example.com" 265 } 266 ``` 267 268 This would mean that an SFTP backend would be created on the fly for 269 the `user` and `pass`/`public_key` returned in the output to the host given. Note 270 that since `_obscure` is set to `pass`, rclone will obscure the `pass` 271 parameter before creating the backend (which is required for sftp 272 backends). 273 274 The program can manipulate the supplied `user` in any way, for example 275 to make proxy to many different sftp backends, you could make the 276 `user` be `user@example.com` and then set the `host` to `example.com` 277 in the output and the user to `user`. For security you'd probably want 278 to restrict the `host` to a limited list. 279 280 Note that an internal cache is keyed on `user` so only use that for 281 configuration, don't use `pass` or `public_key`. This also means that if a user's 282 password or public-key is changed the cache will need to expire (which takes 5 mins) 283 before it takes effect. 284 285 This can be used to build general purpose proxies to any kind of 286 backend that rclone supports. 287 288 289 ``` 290 rclone serve ftp remote:path [flags] 291 ``` 292 293 ## Options 294 295 ``` 296 --addr string IPaddress:Port or :Port to bind server to. (default "localhost:2121") 297 --auth-proxy string A program to use to create the backend from the auth. 298 --dir-cache-time duration Time to cache directory entries for. (default 5m0s) 299 --dir-perms FileMode Directory permissions (default 0777) 300 --file-perms FileMode File permissions (default 0666) 301 --gid uint32 Override the gid field set by the filesystem. (default 1000) 302 -h, --help help for ftp 303 --no-checksum Don't compare checksums on up/download. 304 --no-modtime Don't read/write the modification time (can speed things up). 305 --no-seek Don't allow seeking in files. 306 --pass string Password for authentication. (empty value allow every password) 307 --passive-port string Passive port range to use. (default "30000-32000") 308 --poll-interval duration Time to wait between polling for changes. Must be smaller than dir-cache-time. Only on supported remotes. Set to 0 to disable. (default 1m0s) 309 --public-ip string Public IP address to advertise for passive connections. 310 --read-only Mount read-only. 311 --uid uint32 Override the uid field set by the filesystem. (default 1000) 312 --umask int Override the permission bits set by the filesystem. (default 2) 313 --user string User name for authentication. (default "anonymous") 314 --vfs-cache-max-age duration Max age of objects in the cache. (default 1h0m0s) 315 --vfs-cache-max-size SizeSuffix Max total size of objects in the cache. (default off) 316 --vfs-cache-mode CacheMode Cache mode off|minimal|writes|full (default off) 317 --vfs-cache-poll-interval duration Interval to poll the cache for stale objects. (default 1m0s) 318 --vfs-case-insensitive If a file name not found, find a case insensitive match. 319 --vfs-read-chunk-size SizeSuffix Read the source objects in chunks. (default 128M) 320 --vfs-read-chunk-size-limit SizeSuffix If greater than --vfs-read-chunk-size, double the chunk size after each chunk read, until the limit is reached. 'off' is unlimited. (default off) 321 --vfs-read-wait duration Time to wait for in-sequence read before seeking. (default 20ms) 322 --vfs-write-wait duration Time to wait for in-sequence write before giving error. (default 1s) 323 ``` 324 325 See the [global flags page](/flags/) for global options not listed here. 326 327 ## SEE ALSO 328 329 * [rclone serve](/commands/rclone_serve/) - Serve a remote over a protocol. 330