Skip to main content

Install Ntfy server on Debian linux.

The below guide is to install ntfy server on a self-hosted Debian linux.

1. Install the Ntfy Server.

Go on the root folder 

cd /root
Make the install script file
nano install-ntfy.sh

copy and paste the below code

#!/bin/bash

# Update package lists and upgrade existing packages
apt update && apt dist-upgrade -y

# Install required packages for HTTPS transport, curl, and GPG
apt install -y apt-transport-https curl gpg

# Create directory for GPG keyrings if it doesn't exist
mkdir -p /etc/apt/keyrings

# Download the public key and store it securely
curl -fsSL https://archive.heckel.io/apt/pubkey.txt | gpg --dearmor -o /etc/apt/keyrings/archive.heckel.io.gpg

# Add the repository to sources list if not already present
REPO_FILE="/etc/apt/sources.list.d/archive.heckel.io.list"
if [ ! -f "$REPO_FILE" ]; then
    echo 'deb [arch=amd64 signed-by=/etc/apt/keyrings/archive.heckel.io.gpg] https://archive.heckel.io/apt debian main' > "$REPO_FILE"
fi

# Update package lists again to include new repository
apt update

# Install ntfy from the repository
apt install -y ntfy

# Enable and start the ntfy systemd service for automatic startup
systemctl enable ntfy
systemctl start ntfy

Press Ctrl + x to save then press  and press  enter 

Make the script executable
chmod +x install-ntfy.sh

Execute the install-ntfy.sh and install Ntfy Server

./install-ntfy.sh

Setting up Ntfy configuration

The ntfy config files, both for server and clients are store at  /etc/ntfy 

Now go to that path

# Go to the ntfy directory
cd /etc/ntfy
# List the files inside the ntfy directory
ls -al
Configuring Ntfy Server

Before we continue with the server configuration yaml file, let's make a copy first of the example  server.yml  then we will work the original file not the bak. We will keep ONLY the setting we need for now for make the server.yml simplier. If need extra configuration then check the server.yml.bak file that have all the settings and explanations for them.
You can also check the documentation https://push.greenhome.stream/docs/

# Make a backup copy of the orignal file server.yml
cp server.yml server.yml.bak
# Edit the server.yml file
nano server.yml

Press  Ctrl + k  and holded until you erase all line from the server.ym file.
Copy and paste the below example setting and change them according to your needs.

## Base settings
base-url: "http://your-ip.or-domain.com"
listen-http: ":80"
# listen-https:
# key-file: <filename>
# cert-file: <filename>

## Auth settings
auth-file: /var/lib/ntfy/user.db
auth-default-access: "deny-all"
enable-signup: true
enable-login: true
# enable-reservations: false
# auth-startup-queries:

## Proxy
behind-proxy: true

## Cache file
cache-file: "/var/cache/ntfy/cache.db"
cache-duration: "24h"

## Cache attachment size
attachment-cache-dir: "/var/cache/ntfy/attachments"
attachment-total-size-limit: "5G"
attachment-file-size-limit: "150M"
attachment-expiry-duration: "24h"

## ios
upstream-base-url: "https://ntfy.sh"

## Logs settings
log-level: info
log-format: json
log-file: "/var/log/ntfy.log"

You have to create the  ntfy.log  file and give it permission of the ntfy user.

## Create the log file
touch /var/log/ntfy.log
## Assign permission to ntfy user
chown ntfy:ntfy /var/log/ntfy.log

Now you have to restart the ntfy service for the changes to be apply.

systemctl restart ntfy

Now go to your instance where is hosted ntfy server refresh the browser and you will up-right a Sign IN and Sign UP buttons, to sign up and start to make use of the ntfy.

Add users.

You can add user from the Web UI by sign up OR you can add user from the command cli of the host where ntfy is hosted.
At the below example we add a user with a name  xristina 

ntfy user add xristina

And then it will prompt you to put the password for the user you want to add. This user is create like a simple user that means it can create topics but it can read/write topics only that user create. To have access to other topics so it can read or read/write them you must give his that access, check below Give access to user.

List users.

To list the users run the below command.

ntfy user list
Change the Role of a user.

You can change the role of a use from the command cli with the below commands.
At the below example we change role to user  xristina  to be  admin 
Roles are : admin, pro, user,

ntfy user change-role xristina admin
Give access to user for a topic to read or read/write.

At the below example we give access to user  xristina  to topic  test 

ntsy access xristina test rw

Ins0mniA