github.com/ncw/rclone@v1.48.1-0.20190724201158-a35aa1360e3e/docs/content/commands/rclone_serve_sftp.md (about)

     1  ---
     2  date: 2019-06-20T16:09:42+01:00
     3  title: "rclone serve sftp"
     4  slug: rclone_serve_sftp
     5  url: /commands/rclone_serve_sftp/
     6  ---
     7  ## rclone serve sftp
     8  
     9  Serve the remote over SFTP.
    10  
    11  ### Synopsis
    12  
    13  rclone serve sftp implements an SFTP server to serve the remote
    14  over SFTP.  This can be used with an SFTP client or you can make a
    15  remote of type sftp to use with it.
    16  
    17  You can use the filter flags (eg --include, --exclude) to control what
    18  is served.
    19  
    20  The server will log errors.  Use -v to see access logs.
    21  
    22  --bwlimit will be respected for file transfers.  Use --stats to
    23  control the stats printing.
    24  
    25  You must provide some means of authentication, either with --user/--pass,
    26  an authorized keys file (specify location with --authorized-keys - the
    27  default is the same as ssh) or set the --no-auth flag for no
    28  authentication when logging in.
    29  
    30  Note that this also implements a small number of shell commands so
    31  that it can provide md5sum/sha1sum/df information for the rclone sftp
    32  backend.  This means that is can support SHA1SUMs, MD5SUMs and the
    33  about command when paired with the rclone sftp backend.
    34  
    35  If you don't supply a --key then rclone will generate one and cache it
    36  for later use.
    37  
    38  By default the server binds to localhost:2022 - if you want it to be
    39  reachable externally then supply "--addr :2022" for example.
    40  
    41  Note that the default of "--vfs-cache-mode off" is fine for the rclone
    42  sftp backend, but it may not be with other SFTP clients.
    43  
    44  
    45  ### Directory Cache
    46  
    47  Using the `--dir-cache-time` flag, you can set how long a
    48  directory should be considered up to date and not refreshed from the
    49  backend. Changes made locally in the mount may appear immediately or
    50  invalidate the cache. However, changes done on the remote will only
    51  be picked up once the cache expires.
    52  
    53  Alternatively, you can send a `SIGHUP` signal to rclone for
    54  it to flush all directory caches, regardless of how old they are.
    55  Assuming only one rclone instance is running, you can reset the cache
    56  like this:
    57  
    58      kill -SIGHUP $(pidof rclone)
    59  
    60  If you configure rclone with a [remote control](/rc) then you can use
    61  rclone rc to flush the whole directory cache:
    62  
    63      rclone rc vfs/forget
    64  
    65  Or individual files or directories:
    66  
    67      rclone rc vfs/forget file=path/to/file dir=path/to/dir
    68  
    69  ### File Buffering
    70  
    71  The `--buffer-size` flag determines the amount of memory,
    72  that will be used to buffer data in advance.
    73  
    74  Each open file descriptor will try to keep the specified amount of
    75  data in memory at all times. The buffered data is bound to one file
    76  descriptor and won't be shared between multiple open file descriptors
    77  of the same file.
    78  
    79  This flag is a upper limit for the used memory per file descriptor.
    80  The buffer will only use memory for data that is downloaded but not
    81  not yet read. If the buffer is empty, only a small amount of memory
    82  will be used.
    83  The maximum memory used by rclone for buffering can be up to
    84  `--buffer-size * open files`.
    85  
    86  ### File Caching
    87  
    88  These flags control the VFS file caching options.  The VFS layer is
    89  used by rclone mount to make a cloud storage system work more like a
    90  normal file system.
    91  
    92  You'll need to enable VFS caching if you want, for example, to read
    93  and write simultaneously to a file.  See below for more details.
    94  
    95  Note that the VFS cache works in addition to the cache backend and you
    96  may find that you need one or the other or both.
    97  
    98      --cache-dir string                   Directory rclone will use for caching.
    99      --vfs-cache-max-age duration         Max age of objects in the cache. (default 1h0m0s)
   100      --vfs-cache-mode string              Cache mode off|minimal|writes|full (default "off")
   101      --vfs-cache-poll-interval duration   Interval to poll the cache for stale objects. (default 1m0s)
   102      --vfs-cache-max-size int             Max total size of objects in the cache. (default off)
   103  
   104  If run with `-vv` rclone will print the location of the file cache.  The
   105  files are stored in the user cache file area which is OS dependent but
   106  can be controlled with `--cache-dir` or setting the appropriate
   107  environment variable.
   108  
   109  The cache has 4 different modes selected by `--vfs-cache-mode`.
   110  The higher the cache mode the more compatible rclone becomes at the
   111  cost of using disk space.
   112  
   113  Note that files are written back to the remote only when they are
   114  closed so if rclone is quit or dies with open files then these won't
   115  get written back to the remote.  However they will still be in the on
   116  disk cache.
   117  
   118  If using --vfs-cache-max-size note that the cache may exceed this size
   119  for two reasons.  Firstly because it is only checked every
   120  --vfs-cache-poll-interval.  Secondly because open files cannot be
   121  evicted from the cache.
   122  
   123  #### --vfs-cache-mode off
   124  
   125  In this mode the cache will read directly from the remote and write
   126  directly to the remote without caching anything on disk.
   127  
   128  This will mean some operations are not possible
   129  
   130    * Files can't be opened for both read AND write
   131    * Files opened for write can't be seeked
   132    * Existing files opened for write must have O_TRUNC set
   133    * Files open for read with O_TRUNC will be opened write only
   134    * Files open for write only will behave as if O_TRUNC was supplied
   135    * Open modes O_APPEND, O_TRUNC are ignored
   136    * If an upload fails it can't be retried
   137  
   138  #### --vfs-cache-mode minimal
   139  
   140  This is very similar to "off" except that files opened for read AND
   141  write will be buffered to disks.  This means that files opened for
   142  write will be a lot more compatible, but uses the minimal disk space.
   143  
   144  These operations are not possible
   145  
   146    * Files opened for write only can't be seeked
   147    * Existing files opened for write must have O_TRUNC set
   148    * Files opened for write only will ignore O_APPEND, O_TRUNC
   149    * If an upload fails it can't be retried
   150  
   151  #### --vfs-cache-mode writes
   152  
   153  In this mode files opened for read only are still read directly from
   154  the remote, write only and read/write files are buffered to disk
   155  first.
   156  
   157  This mode should support all normal file system operations.
   158  
   159  If an upload fails it will be retried up to --low-level-retries times.
   160  
   161  #### --vfs-cache-mode full
   162  
   163  In this mode all reads and writes are buffered to and from disk.  When
   164  a file is opened for read it will be downloaded in its entirety first.
   165  
   166  This may be appropriate for your needs, or you may prefer to look at
   167  the cache backend which does a much more sophisticated job of caching,
   168  including caching directory hierarchies and chunks of files.
   169  
   170  In this mode, unlike the others, when a file is written to the disk,
   171  it will be kept on the disk after it is written to the remote.  It
   172  will be purged on a schedule according to `--vfs-cache-max-age`.
   173  
   174  This mode should support all normal file system operations.
   175  
   176  If an upload or download fails it will be retried up to
   177  --low-level-retries times.
   178  
   179  
   180  ```
   181  rclone serve sftp remote:path [flags]
   182  ```
   183  
   184  ### Options
   185  
   186  ```
   187        --addr string                            IPaddress:Port or :Port to bind server to. (default "localhost:2022")
   188        --authorized-keys string                 Authorized keys file (default "~/.ssh/authorized_keys")
   189        --dir-cache-time duration                Time to cache directory entries for. (default 5m0s)
   190        --dir-perms FileMode                     Directory permissions (default 0777)
   191        --file-perms FileMode                    File permissions (default 0666)
   192        --gid uint32                             Override the gid field set by the filesystem. (default 1000)
   193    -h, --help                                   help for sftp
   194        --key string                             SSH private key file (leave blank to auto generate)
   195        --no-auth                                Allow connections with no authentication if set.
   196        --no-checksum                            Don't compare checksums on up/download.
   197        --no-modtime                             Don't read/write the modification time (can speed things up).
   198        --no-seek                                Don't allow seeking in files.
   199        --pass string                            Password for authentication.
   200        --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)
   201        --read-only                              Mount read-only.
   202        --uid uint32                             Override the uid field set by the filesystem. (default 1000)
   203        --umask int                              Override the permission bits set by the filesystem. (default 2)
   204        --user string                            User name for authentication.
   205        --vfs-cache-max-age duration             Max age of objects in the cache. (default 1h0m0s)
   206        --vfs-cache-max-size SizeSuffix          Max total size of objects in the cache. (default off)
   207        --vfs-cache-mode CacheMode               Cache mode off|minimal|writes|full (default off)
   208        --vfs-cache-poll-interval duration       Interval to poll the cache for stale objects. (default 1m0s)
   209        --vfs-read-chunk-size SizeSuffix         Read the source objects in chunks. (default 128M)
   210        --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)
   211  ```
   212  
   213  See the [global flags page](/flags/) for global options not listed here.
   214  
   215  ### SEE ALSO
   216  
   217  * [rclone serve](/commands/rclone_serve/)	 - Serve a remote over a protocol.
   218