Skip to content

Instantly share code, notes, and snippets.

@dhsathiya
Last active April 25, 2022 01:23
Show Gist options
  • Save dhsathiya/2270308c911865e576e1909cbba9ae9a to your computer and use it in GitHub Desktop.
Save dhsathiya/2270308c911865e576e1909cbba9ae9a to your computer and use it in GitHub Desktop.
ZSH command logging with SSH Client IP

Add following in .zshrc

preexec() {
    echo "[$(date +%d/%m/%Y-%H:%M:%S)] $(echo $SSH_CLIENT | awk '{ print $1}') - $1" >> /var/log/command.log
}
@dhsathiya
Copy link
Author

Similar can be achieved with trap ____ debug on .bashrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment