Skip to content

Instantly share code, notes, and snippets.

@ahmetozer
Last active July 14, 2020 21:03
Show Gist options
  • Save ahmetozer/27da680c549b0600483bfa5794807bef to your computer and use it in GitHub Desktop.
Save ahmetozer/27da680c549b0600483bfa5794807bef to your computer and use it in GitHub Desktop.
SSH log command
# Do not forget add these lines to /etc/ssh/sshd_config
Match User test
ForceCommand "/bin/sshlogexec.sh"
#!/bin/bash
LOG="$USER $SSH_CONNECTION $(date)"
LOGFILE="/var/log/sshexec.log"
LOGFILE="/var/log/sshexec.log"
if [ -z "$SSH_ORIGINAL_COMMAND" ]
then
bash
else
echo $LOG : $SSH_ORIGINAL_COMMAND >> $LOGFILE
$SSH_ORIGINAL_COMMAND
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment