Skip to main content

How to be Notified of each SFTP access to server

Comments

3 comments

  • cPRex Jurassic Moderator
    Hey there! I looked around for a bit as well, but I didn't find anything ready-made for this either. This sounds like a great idea for a feature request, though, and you can get that submitted using the link in my signature.
    0
  • martin MHC
    I CPRex, I am currently researching writing a shim bash script to carry out this task, and will update if/when I get progress on doing this! Cheers
    0
  • martin MHC
    A useful script for emailing these details when a SFTP connection is CLOSED is: 1. Upload the below code (adjusting as required) 2. Update the sshd_config file 3. Restart sshd (using WHM restart is fine) .... #!/bin/bash # Create a temporary log file LOGFILE=$(/bin/mktemp /tmp/sftplog.XXXXXX) # Redirect stderr to LOGFILE exec 2>"$LOGFILE" # Run the SFTP with logging to stderr /usr/libexec/openssh/sftp-server -e -u 022 -l VERBOSE exec >/dev/null # Use some sendmail substitute to send an e-mail /usr/sbin/sendmail -i root@localhost <
    NOTE: The file must have the same permissions set as the /usr/libexec/openssh/sftp-server
    THe file can be placed anywhere, say for example usr/local/bin/sftp-logger and then referenced from the etc/ssh/sshd_config file, for example; # override default of no subsystems #Subsystem sftp /usr/libexec/openssh/sftp-server Subsystem sftp /usr/local/bin/sftp-logger
    0

Please sign in to leave a comment.