Ntfy: push notification for services.

I am using Ntfy for my SSH alert and watchtower update. It is pretty cool to have this feature, so I can know who is accessing my server without my authorization. And know my docker needs to be updated as well.

SSH Alert Example

Command this to open code,

nano /etc/pam.d/sshd

Please add this code to the bottom of the page.

session optional pam_exec.so /usr/local/bin/ntfy-ssh-login.sh

You should create a script file called /usr/local/bin/ntfy-ssh-login.sh

nano /usr/local/bin/ntfy-ssh-login.sh

Here code, make sure you change the server URL and username and password for nginx auth.

# This is a PAM script hook that shows how to notify you when
# somebody logs into your server. Place at /usr/local/bin/ntfy-ssh-login.sh (with chmod +x!).


if [ "${PAM_TYPE}" = "open_session" ]; then
  curl -u ${NGINXUSER}:${NGINXPASSWORD} -H tags:warning -H prio:high -d "SSH login to $(hostname): ${PAM_USER} from ${PAM_RHOST}" "${TOPIC_URL}"

Then Now you save Ctrl +x then yes

Make sure you have chmod permissions. Here is the command.

chmod +x /usr/local/bin/ntfy-ssh-login.sh

Go try logging into another terminal and see if it notifications you, then try logging in again and see if it notifications you. 🙂

It works well. It shows the username and IP address, so the IT team can protect the account if they don’t have permission to access our server.


2 responses to “Ntfy: push notification for services.”

  1. hiI like your writing so much share we be in contact more approximately your article on AOL I need a specialist in this area to resolve my problem Maybe that is you Looking ahead to see you

    1. Hello whom,

      Of course I can help you anything issues relate Linux, Windows, Apple, let me know if you need assistance

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.