Get notified when someone logs into SSH on a server, easily through a Discord Webhook. This works with both password and ssh key logins.
By default, it pings everyone when someone has logged in. However, this can be changed in the config.
- Awareness. You know when someone has logged in, so you can react quickly if it wasn't you.
- You can change the discord webhook message easily.
- A server running NodeJS, NPM and Git
- A discord server, account and webhook.
- For this guide, you need a Debian based system. This will work on other distros too, though.
# Install required packages
sudo apt install npm git
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
apt update
apt install nodejs
# Clone files
git clone https://github.com/guldkage/SSHLogger/
cd SSHLogger
# Install requirements
npm i
# Edit the config (any editor)
nano config.yaml
# Start SSHLogger
node index.js
To run SSHLogger in background, it can be created in a systemd service to run in the background and start automatically at machine startup.
cp sshlogger.service /etc/systemd/system/sshlogger.service
# You might need to change WorkingDirectory, unless SSHLogger is in root directory.
nano /etc/systemd/system/sshlogger.service
systemctl daemon-reload
systemctl enable sshlogger --now