3

I am using the current OpenSSH version on Debian 7.7 Whezzy, which is, according to dpkg, 1:6.0p1-4+deb7u2.

I configured OpenSSH to allow clients to connect using SFTP, and read and modify (upload or replace) arbitrary files in a chroooted environment.

I want a script to be triggered whenever a change (deletion, upload or replacement) occurs, and, if possible, as well if the change succeeded or failed.

For example, if Alice uploads a file /foo/bar.png, a script notify.sh alice /home/alice/foo/bar.png UPLOAD SUCCESS would be invoked.

Is there a way to realize this?

muffel
  • 302
  • 7
  • 20

1 Answers1

1

AFAIK OpenSSH doesn't have a support for that. <opinion>The probable reason behind that, that the OpenSSH guys favorize the minimal feature, maximal security concept which is quite visible on their other projects, too.</opinion> But it is not unconditionally a problem.

  1. You can do this by watching the system log, and setting up condition for that (at least syslog-ng can do this).
  2. There is incron for the task. It is a daemon, using the inotify feature of the linux kernel to call scripts, triggered by file changes.
peterh
  • 4,914
  • 13
  • 29
  • 44
  • would this allow to detect interrupted uploads (e.g. the connection of Alice gets interrupted during file transfer)? – muffel Jan 27 '15 at 20:34
  • @muffel I would do this with log watching, incron can see only file operations. – peterh Jan 27 '15 at 20:35
  • 2
    @muffel For interrupted downloads, see [How to detect or log interrupted uploads with OpenSSH SFTP server?](http://serverfault.com/q/652629/168875) – Martin Prikryl Jan 27 '15 at 20:40