Skip to content

Instantly share code, notes, and snippets.

@gbarboza
Last active January 4, 2016 01:18
Show Gist options
  • Select an option

  • Save gbarboza/8547035 to your computer and use it in GitHub Desktop.

Select an option

Save gbarboza/8547035 to your computer and use it in GitHub Desktop.
# SSH1 only
command="log-and-run" ...key...
where log-and-run is the following script. It appends a line to a log file, containing a timestamp and the command attempted:
#!/bin/sh
if [ -n "$SSH_ORIGINAL_COMMAND" ]
then
echo "`/bin/date`: $SSH_ORIGINAL_COMMAND" >> $HOME/ssh-command-log
exec $SSH_ORIGINAL_COMMAND
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment