Jump to content

Recommended Posts

Posted

Здравствуйте. Поиск ничего не дал, поэтому решил написать.
На Ubuntu 20.04, у меня настроены уведомления, с отправкой сообщения в Телеграм.
Там это реализовано так, создал скрипт, закинул его в директорию /etc/profile.d/ssh-to-telegram-notififations.sh

USERID="мой юзер айди"
KEY="мой апи токен"
TIMEOUT="10"
URL="https://api.telegram.org/bot$KEY/sendMessage"
DATE_EXEC="$(date "+%d %B %Y %H:%M")"
if [ -n "$SSH_CLIENT" ]; then
        IP=$(awk '{print $1}' <<< $SSH_CLIENT)
        PORT=$(awk '{print $3}' <<< $SSH_CLIENT)
        HOSTNAME=$(hostname -f)
        IPADDR=$(hostname -I | awk '{print $1}')
        TEXT="$DATE_EXEC
        Вход пользователя ${USER} по ssh на $HOSTNAME ($IPADDR)
        С $IP через порт $PORT"
        curl -s --max-time $TIMEOUT -d "chat_id=$USERID&disable_web_page_preview=1&text=$TEXT" $URL > /dev/null
fi

И все работает.

А как реализовать это в Entware, не пойму. 

2021-03-15_10-11-37.png

  • Thanks 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

This site uses cookies. By clicking "I accept" or continuing to browse the site, you authorize their use in accordance with the Privacy Policy.