lockingsftptransfer

SFTP file lock mechanism


How can I make sure that a file uploaded through SFTP (in a Linux base system) stays locked during the transfer so an automated system will not read it?

Is there an option on the client side? Or server side?


Solution

  • SFTP protocol supports locking since version 5. See the specification.

    You didn't specify, what SFTP server are you using. So I'm assuming the most widespread one, the OpenSSH. The OpenSSH supports SFTP version 3 only, so it does not support locking.

    Anyway, even if your server supported file locking, most SFTP clients/libraries won't support SFTP version 5. Or even if they do, they won't support the locking feature. Note that the lock is explicit, the client has to request it.


    There are some common workarounds for the problem: