Last active
July 14, 2020 21:03
-
-
Save ahmetozer/27da680c549b0600483bfa5794807bef to your computer and use it in GitHub Desktop.
SSH log command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Do not forget add these lines to /etc/ssh/sshd_config | |
Match User test | |
ForceCommand "/bin/sshlogexec.sh" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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