5

I am trying to setup a SFTP server, running off Ubuntu Server 11.04. I installed openssh-server to provide SSH access. What I am trying to do is make file uploads run with a suffix (.filepart or whatever), which would be removed upon transfer completion.

The flow idea is:

  1. User uploads cat.jpg
  2. The server starts writing cat.jpg.filepart in the destination directory
  3. Once the upload completes, the server trashes the previous cat.jpg (if any) and renames cat.jpg.filepart to cat.jpg

This is to make sure that incomplete file uploads do not overwrite the existing files. Any idea on how I can do this?

Thanks

4 Answers4

4

The OpenSSH server does not support this.

WinSCP SFTP client can do this from a client side, if that helps.

See https://winscp.net/eng/docs/resume#automatic

By default is uses the .filepart suffix for files over 100 KB only, but you can configure it to use it for any file.

See https://winscp.net/eng/docs/ui_pref_resume

(I'm the author of WinSCP)

Martin Prikryl
  • 7,756
  • 2
  • 39
  • 73
2

Use rsync (over ssh). It's designed to not destroy existing files if copies fail half way through.

EightBitTony
  • 9,311
  • 1
  • 34
  • 46
  • Well, this is not a viable option since it is supposed to be used by non tech users (read manager, executive class). We can ask them to use SFTP upload because most are familiar with FileZilla/CyberDuck/WinSCP, but certainly not command line + rsync. – The Mighty Rubber Duck Jun 23 '11 at 02:04
2

If you are able to write Perl, you could write your customized SFTP server on top of Net::SFTP::Server/Net::SFTP::Server::FS.

Update: see sftp-server-atomic-put.pl

salva
  • 254
  • 1
  • 7
2

ProFTPD can support SFTP via the mod_sftp module, and can do just what you describe with its HiddenStores directive; this functionality is supported for both FTP and SFTP uploads.

Full disclosure: I'm the author of ProFTPD and mod_sftp.

Castaglia
  • 3,349
  • 3
  • 21
  • 42