You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.9 KiB
3.9 KiB
Alias | Tag | Date | DocType | Hierarchy | TimeStamp | location | CollapseMetaTable | ||
---|---|---|---|---|---|---|---|---|---|
2022-03-10 | Yes |
Parent:: Selfhosting, Server Alias, Server Cloud, Server Tools, Server VPN
name Save
type command
action Save current file
id Save
^button-ConfiguringTelegrambotsNSave
Configuring Telegram bots
title: Summary
collapse: open
This note allows to configure Telegram bots for pairing with certain services.
style: number
Linking services with a Telegram bot
Creating a Telegram Bot
- In Telegram, look for '@BotFather'
- Initialise with
/start
- Create bot with
/newbot
Record the Token from the message from BotFather.
Getting the Bot's Chat ID
In a terminal, run:
title: Telegram Chat ID
~~~bash
curl https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/getUpdates | jq .message.chat.id
~~~
Linking Logwatch
Please see full documentation GitHub - fxkjdlogwatch-telegram-bot Send logwatch results to your telegram account.
Linking monit
Please see full documentation GitHub - matriphemonit2telegram A simple script to send Monit alerts using Telegram bot..
Linking fail2ban
Please see full documentation GitHub - deividgdtfail2ban_telegram_notifications Sending fail2ban notifications using a Telegram bot for SSH monitoring.
Postfix Monitoring
In order to monitor SMTP connections through Fail2Ban, a few steps need to be taken.
- Open the conf file
~~~bash
/etc/fail2ban/jail.conf
~~~
Or
~~~bash
/etc/fail2ban/jail.local
~~~
- Edit Postfix & create Postfix-auth
~~~bash
[postfix]
enabled = true
maxretry = 3
bantime = 1h
filter = postfix[mode=aggressive]
telegram
mode = more
port = smtp,465,submission
logpath = %(postfix_log)s
backend = %(postfix_backend)s
[postfix-auth]
enabled = true
bantime = 1h
filter = postfix.auth
action = iptables-multiport[name=postfix, port="http,https,smtp,submission,pop3,pop3s,imap,imaps,sieve”, protocol=tcp]
telegram
logpath = /var/log/mail.log
ignoreip = 127.0.0.1/8
maxretry = 3
~~~
- Create postfix.auth filter
/etc/fail2ban/filter.d/postfix.auth.conf
~~~bash
[Definition]
failregex = lost connection after AUTH from (.*)\[<HOST>\]
ignoreregex =
~~~
- Restart fail2ban
~~~bash
sudo systemctl restart fail2ban
~~~
Current bots
Logwatch and Monit
A bot has been created for Configuring Monit and Logwatch.
title: Credentials
| Variable | Value
| - | -
| Name | Logwatch_servers
| Username | [mbvservers_bot](https://t.me/mbvservers_bot)
| Token | 5218097204:AAEnsZLTk4TTk-X-MceuoIGX0IQWLkngM4E
| Chat ID | 1622082350
Alias Server
title: Credentials
| Variable | Value
| - | -
| Name | Alias Server
| Username | [AliasServer_bot](https://t.me/AliasServer_bot)
| Token | 5152026161:AAEz4uzDmu8NwrQ5keVmeQNoW4crFVNA0Mg
| Chat ID | 1622082350
Cloud Server
title: Credentials
| Variable | Value
| - | -
| Name | Cloud Server
| Username | [CloudServer_mfxm_bot](https://t.me/CloudServer_mfxm_bot)
| Token | 5195880175:AAHn9EeBWX0tNszSX4MvWUtJ2I3K8wmCIKw
| Chat ID | 1622082350
Tools Server
title: Credentials
| Variable | Value
| - | -
| Name | Tools Server
| Username | [Tools_mfxm_bot](https://t.me/Tools_mfxm_bot)
| Token | 5084726395:AAGCxr7VvG_fsrO7JWexlQgPt3dtwCijKjY
| Chat ID | 1622082350
VPN Server
title: Credentials
| Variable | Value
| - | -
| Name | VPN Server
| Username | [VPN_mfxm_bot](https://t.me/VPN_mfxm_bot)
| Token | 5159102890:AAFt6QIaUiWZsskc9CFveJBHORjmZYgzTiE
| Chat ID | 1622082350