Telegram Bot, which reads logs from UFW and sends notifications to telegram channel when there are blocked/audited/allowed connections. Run with sudo.
Bot reads the configuration file, parses the path to the file to be followed, parses the Telegram bot API token, parses the channel to which updates are sent, and does other things. After that, the bot uses this information to wait for new changes in the log file and sends messages to the channel in pretty format.
Here is the example of messages sent to the channel.
Note the vital port that was distinguished with !! emoji. I setted this up in the settings, when had added the Redis's port (6379) to vital ports in config.yml
.
Send a message to the new channel and copy link of the message. You'll find a channel ID in the link (between two slashes). Add -100
before the ID and note it for the future.
Just clone this project to your server and run go build
. Otherwise you can use prebuilt binary from releases (if it persists).
Add the Bot API token and channel's ID to the config. Use config-example.yml
template from the root of the repository.
Don't forget to rename a config file.
Add vital ports, which are important ports you want to distinguish in the channel with updates.
- Run the executable with sudo
- Use
nohup
or something like that to keep program running even if you're exiting from the server - Check if everything is working