How to Install Zabbix 7 Proxy in Raspberry PI with CloudFlare, RustDesk and Kiosk Mode
Complete tutorial: Zabbix 7 (Agent2 / Proxy) works with Raspberry PI 4 / 5
Updated to Raspberry PI Trixie OS
What you will get

Where did I buy my Raspberry PI5

Install Raspberry Pi OS
Download Raspberry Pi Imager for your SO









Find NEW IP in your Network
Using fping
┌─[jarbelix@jarbelix-Nitro-AN515-44]─[~]─[sáb out 05 08:32:30]
└──╼ $ fping -a -s -4 -q -g 192.168.15.0/24
...
192.168.15.94 <==== This IP did not exist before in my network
...
254 targets
15 alive
239 unreachable
0 unknown addresses
956 timeouts (waiting for response)
971 ICMP Echos sent
15 ICMP Echo Replies received
944 other ICMP received
0.085 ms (min round trip time)
34.3 ms (avg round trip time)
227 ms (max round trip time)
9.176 sec (elapsed real time)
Using nmap
┌─[jarbelix@jarbelix-Nitro-AN515-44]─[~]─[sáb out 05 08:32:30]
└──╼ $ nmap 192.168.15.0/24 -p 22 | grep 'open' -B4 | grep 'Nmap scan report for'
...
Nmap scan report for 192.168.15.94
...
Access Raspberry Pi OS with ssh
First Conect with password
┌─[jarbelix@jarbelix-Nitro-AN515-44]─[~]─[sáb out 05 08:32:44]
└──╼ $ ssh-copy-id -o PreferredAuthentications=password tiozao@192.168.15.94
The authenticity of host '192.168.15.94 (192.168.15.94)' can't be established.
ED25519 key fingerprint is SHA256:zREBygCcKcHm+ZrD48Xd85RAYrfrCKOslUNx/btpZic.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
tiozao@192.168.15.94's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh -o 'PreferredAuthentications=password' 'tiozao@192.168.15.94'"
and check to make sure that only the key(s) you wanted were added.
┌─[jarbelix@jarbelix-Nitro-AN515-44]─[~]─[sáb out 05 08:33:10]
└──╼ $ ssh tiozao@192.168.15.94
Linux raspberrypi 6.6.31+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Jul 3 20:17:00 2024
tiozao@raspberrypi:~ $ sudo cp ~/.ssh/authorized_keys /root/.ssh/
tiozao@raspberrypi:~ $
logout
Connection to 192.168.15.94 closed.
First connection directly as root with your private key
┌─[jarbelix@jarbelix-Nitro-AN515-44]─[~]─[sáb out 05 08:39:08]
└──╼ $ ssh root@192.168.15.94
Linux raspberrypi 6.6.31+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@raspberrypi:~#
Update EEPROM
root@raspberrypi:~# rpi-eeprom-update -a
*** PREPARING EEPROM UPDATES ***
BOOTLOADER: update available
CURRENT: seg 23 set 2024 13:02:56 UTC (1727096576)
LATEST: qua 22 jan 2025 00:16:51 UTC (1737505011)
RELEASE: default (/usr/lib/firmware/raspberrypi/bootloader-2712/default)
Use raspi-config to change the release.
CURRENT: seg 23 set 2024 13:02:56 UTC (1727096576)
UPDATE: qua 22 jan 2025 00:16:51 UTC (1737505011)
BOOTFS: /boot/firmware
'/tmp/tmp.xkTRnuxbcy' -> '/boot/firmware/pieeprom.upd'
UPDATING bootloader. This could take up to a minute. Please wait
*** Do not disconnect the power until the update is complete ***
If a problem occurs then the Raspberry Pi Imager may be used to create
a bootloader rescue SD card image which restores the default bootloader image.
flashrom -p linux_spi:dev=/dev/spidev10.0,spispeed=16000 -w /boot/firmware/pieeprom.upd
Verifying update
VERIFY: SUCCESS
UPDATE SUCCESSFUL
root@raspberrypi:~#
root@raspberrypi:~# reboot
root@raspberrypi:~# Connection to 192.168.15.94 closed by remote host.
Connection to 192.168.15.94 closed
Tiozão Customization
Timezone and Locale Settings
timedatectl set-timezone America/Campo_Grande
apt-get -y install locales
locale-gen pt_BR.UTF-8 en_US.UTF-8
Upgrade OS like RH "dnf upgrade -y --refresh"
cat << '_EOF_' > /root/debian-upgrade.sh
#!/bin/bash
# Simulates a dnf -y upgrade --refresh
#
# 02/Mar/2022 - jarbas.junior@gmail.com - Initial implementation
#
export PATH="/usr/sbin:/usr/bin:$HOME/bin"
# If this script is already running then do nothing.
pidof -x -o %PPID $0 > /dev/null && echo "Script $0 still in execution..." && exit
# Some global variables
#
BASENAME=`basename $0 .Sh`
DIRNAME=`dirname $0`
# Data e Hora Local
DATAHORA=`date +%Y%m%d-%H%M%S`
# Dia da semana (dom, seg, ...)
DDS=`date +%a`
# Get the hostname
HOSTNAME=`hostname -f`
# Server IP (eth0 ou ens192)
IP=`hostname --all-ip-addresses | awk '{ print $1 }'`
# Temp file name
FILE_LOG="/tmp/$BASENAME.log"
# Enable cancel with ^C, etc..
# See more in http://www.ibm.com/developerworks/aix/library/au-usingtraps/
trap _abort 1 2 3 15
#------------------------------------------
# Inform about then cancel
_abort()
{ # BEGIN _abort
echo "!!! $0 CANCEL by user.">&2
exit 1
} # END _abort
{
echo "Begin Execution: `date`"
echo -e "
========== Global Variables ====================================
SCRIPTNAME......: [$0]
BASENAME........: [$BASENAME]
DIRNAME.........: [$DIRNAME]
HOSTNAME........: [$HOSTNAME]
IP..............: [$IP]
DATAHORA........: [$DATAHORA]
FILE_LOG........: [$FILE_LOG]
================================================================
"
# https://www.cyberciti.biz/faq/explain-debian_frontend-apt-get-variable-for-ubuntu-debian/
export NEEDRESTART_MODE=a
export DEBIAN_FRONTEND=noninteractive
## Questions that you really, really need to see (or else). ##
export DEBIAN_PRIORITY=critical
echo "========== apt-get update ================================================="
apt-get -qy update
echo "========== apt-get upgrade -y ============================================="
apt-get -qy upgrade -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold"
echo "========== apt-get dist-upgrade -y ========================================"
apt-get -qy dist-upgrade -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold"
echo "========== apt-get autoremove -y =========================================="
apt-get -qy autoremove
echo "========== apt-get clean all =============================================="
apt-get -qy clean all
echo "==========================================================================="
echo "END: `date`"
} 2>&1 | tee ${FILE_LOG}
_EOF_
# Make executable
chmod +x /root/debian-upgrade.sh
# Add entry to crontab
(crontab -l ; echo "0 3 * * * /root/debian-upgrade.sh >/dev/null 2>&1") | crontab -
# Checking the entry in crontab
crontab -l
0 3 * * * /root/debian-upgrade.sh >/dev/null 2>&1
Install additional packages
export DEBIAN_FRONTEND=noninteractive
apt-get -y install vim fastfetch ccze nmap sysstat net-tools chrony tree boxes xdotool unclutter sed tmux cockpit duf rsync htop rsyslog jq gawk bind9-host bind9-dnsutils wtype postfix
sed -i 's/ENABLED="false"/ENABLED="true"/' /etc/default/sysstat
systemctl enable --now sysstat.service cockpit.service
systemctl disable --now cups.service postfix.service
Tiozão's reception
cat << '_EOF_' > /etc/profile.d/zz-welcome.sh
echo -e "\nTiozão do Linux\ntwitter.com/TiozaoDoLinux\nwiki.TiozaoDoLinux.com" | boxes -d dog -a c -s 80
fastfetch
echo -e "Servidor Raspberry-PI - $HOSTNAME\n\n`date`" | boxes -d parchment -a c -s 80
duf --only local
_EOF_
cat << '_EOF_' > ~/.bash_aliases
alias remove-comments="grep -v -E '^(#|;|$|[[:space:]])'"
alias meuip='curl -s http://ipinfo.io/json/ | jq'
_EOF_
cat << '_EOF_' >> ~/.bashrc
# Alias extra definitions
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# 'history' personalization
HISTCONTROL=ignoredups:ignorespace
shopt -s histappend
HISTSIZE=1000
HISTFILESIZE=2000
HISTTIMEFORMAT="%F %T "
export TERM=xterm
# Root Prompt
PS1='\[\e[1;31m\]\342\224\214\342\224\200\[\e[1;31m\][\[\e[1;33m\]\u\[\e[1;37m\]@\[\e[1;36m\]\H\[\e[1;31m\]]\[\e[1;31m\]\342\224\200\[\e[1;31m\][\[\e[1;33m\]\w\[\e[1;31m\]]\[\e[1;31m\]\342\224\200[\[\e[1;37m\]\d \t\[\e[1;31m\]]\n\[\e[1;31m\]\342\224\224\342\224\200\342\224\200\342\225\274\[\e[1;37m\] \$ \[\e[0m\]'
_EOF_
cat << '_EOF_' >> /root/.vimrc
" Disable vim automatic visual mode on mouse select
"
" issue: :set mouse-=a
" add to ~/.vimrc: set mouse-=a
"
"my ~/.vimrc for preserving global defaults and only changing one option:
"
" Referência: https://gist.github.com/u0d7i/01f78999feff1e2a8361
"
source $VIMRUNTIME/defaults.vim
set mouse-=a
_EOF_
See what personalization looks like when logging in 😎
┌─[jarbelix@jarbelix-Nitro-AN515-44]─[~]─[sáb out 05 10:22:09]
└──╼ $ ssh root@192.168.15.94
Linux raspberrypi 6.6.51+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.51-1+rpt2 (2024-10-01) aarch64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Web console: https://raspberrypi:9090/ or https://192.168.15.94:9090/
Last login: Sat Oct 5 08:59:33 2024 from 192.168.15.10
__ _,--="=--,_ __
/ \." .-. "./ \
/ ,/ _ : : _ \/` \
\ `| /o\ :_: /o\ |\__/
`-'| :="~` _ `~"=: |
\` (_) `/ jgs
.-"-. \ | / .-"-.
.-----------------------{ }--| /,.-'-.,\ |--{ }----------------------.
) (_)_)_) \_/`~-===-~`\_/ (_(_(_) (
( )
) Tiozão do Linux (
( twitter.com/TiozaoDoLinux )
) wiki.TiozaoDoLinux.com (
'------------------------------------------------------------------------------'
_,met$$$$$gg. root@raspberry
,g$$$$$$$$$$$$$$$P. --------------
,g$$P"" """Y$$.". OS: Debian GNU/Linux 13 (trixie) aarch64
,$$P' `$$$. Host: Raspberry Pi 4 Model B Rev 1.5
',$$P ,ggs. `$$b: Kernel: Linux 6.12.47+rpt-rpi-v8
`d$$' ,$P"' . $$$ Uptime: 1 min
$$P d$' , $$P Packages: 1724 (dpkg)
$$: $$. - ,d$$' Shell: bash 5.2.37
$$; Y$b._ _,d$P' Cursor: Adwaita
Y$$. `.`"Y$$$$P"' Terminal: /dev/pts/0
`$$b "-.__ CPU: BCM2711 (4) @ 1.80 GHz
`Y$$b GPU: Broadcom bcm2711-vc5 [Integrated]
`Y$$. Memory: 504.99 MiB / 7.64 GiB (6%)
`$$b. Swap: 0 B / 2.00 GiB (0%)
`Y$$b. Disk (/): 6.83 GiB / 57.97 GiB (12%) - ext4
`"Y$b._ Local IP (eth0): 10.70.0.54/24
`"""" Locale: pt_BR.UTF-8
____________________________________________________________________________
/\ \
\_| Servidor Raspberry-PI - raspberrypi |
| |
| sáb 05 out 2024 10:22:11 -04 |
| _______________________________________________________________________|_
\_/_________________________________________________________________________/
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 2 local devices │
├────────────────┬────────┬───────┬────────┬───────────────────────────────┬──────┬────────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────────┼────────┼───────┼────────┼───────────────────────────────┼──────┼────────────────┤
│ / │ 116.7G │ 5.1G │ 105.7G │ [....................] 4.4% │ ext4 │ /dev/mmcblk0p2 │
│ /boot/firmware │ 510.0M │ 76.4M │ 433.6M │ [##..................] 15.0% │ vfat │ /dev/mmcblk0p1 │
╰────────────────┴────────┴───────┴────────┴───────────────────────────────┴──────┴────────────────╯
List SSID Wifi
raspi-config -> 5 Localization Options -> L4 WLAN Contry -> BR
┌─[root@raspberrypi]─[~]─[sáb out 05 10:22:11]
└──╼ # nmcli dev wifi
IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY
10:72:23:13:B9:8E VIVOFIBRAB990 Infra 6 130 Mbit/s 100 ▂▄▆█ WPA2
10:72:23:13:B9:9B VIVOFIBRA-B990-5G Infra 100 540 Mbit/s 100 ▂▄▆█ WPA2
06:72:23:13:B9:9B VIVOFIBRAB990 Infra 100 540 Mbit/s 100 ▂▄▆█ WPA2
5C:FA:25:15:B7:2A Diretoria.2G Infra 11 540 Mbit/s 49 ▂▄__ WPA2
6C:BA:B8:EB:24:45 Caverna_2.4GHz Infra 1 540 Mbit/s 40 ▂▄__ WPA2
Fail2Ban
Install Fail2Ban
apt-get -y install fail2ban
Configure Fail2Ban
cat << '_EOF' > /etc/fail2ban/jail.local
[DEFAULT]
# This will ignore connection coming from common private networks.
# Note that local connections can come from other than just 127.0.0.1, so
# this needs CIDR range too.
ignoreip = 127.0.0.0/8 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
# "bantime" is the number of seconds that a host is banned.
bantime = 3h
# A host is banned if it has generated "maxretry" during the last "findtime"
findtime = 1h
# "maxretry" is the number of failures before a host get banned.
maxretry = 2
[sshd]
enabled = true
_EOF
Enable Fail2Ban
systemctl enable --now fail2ban.service
Watch the logs
# view status with *Banned IP list*
fail2ban-client status sshd
# unban only one IP
fail2ban-client unban 179.181.176.166
# unban all IPs
fail2ban-client unban --all
# view logs in real time
tail -f /var/log/fail2ban.log | ccze -A
Install Zabbix Agent e Proxy
- See official documentation - https://www.zabbix.com/download?zabbix=7.0&os_distribution=raspberry_pi_os&os_version=12&components=proxy&db=sqlite3&ws=
wget https://repo.zabbix.com/zabbix/7.0/debian-arm64/pool/main/z/zabbix-release/zabbix-release_latest_7.0+debian13_all.deb
dpkg -i zabbix-release_latest_7.0+debian13_all.deb
apt update
apt install -y zabbix-get zabbix-sender zabbix-agent2 zabbix-agent2-plugin-* zabbix-proxy-sqlite3
Change your hostname
hostnamectl hostname rasp-pi5-01.tiozaodolinux.com
sed -i -e "s/^127.0.1.1.*$/127.0.1.1\traspberry `hostname`/" /etc/hosts
sed -i -e "s/preserve_hostname: false/preserve_hostname: true/" /etc/cloud/cloud.cfg
How to avoid automatic change of Raspberry hostname - https://www.alauda.ro/2026/01/avoid-your-raspberry-hostname-being-changed/
Configuring Zabbix-Agent2
# make a copy of the original configuration
cp /etc/zabbix/zabbix_agent2.conf /etc/zabbix/zabbix_agent2.conf.orig
cat << '_EOF' > /etc/zabbix/zabbix_agent2.conf
PidFile=/var/run/zabbix/zabbix_agent2.pid
LogFile=/var/log/zabbix/zabbix_agent2.log
LogFileSize=0
Timeout=30
Server=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
ServerActive=zabbix.tiozaodolinux.com
#Hostname=rasp-pi5-01.tiozaodolinux.com
TLSConnect=psk
TLSAccept=unencrypted,psk
TLSPSKIdentity=PSK RASP-PI5-01
TLSPSKFile=/etc/zabbix/zabbix_secret_key.psk
AllowKey=system.run[*]
Plugins.SystemRun.LogRemoteCommands=1
ControlSocket=/run/zabbix/agent.sock
Include=/etc/zabbix/zabbix_agent2.d/*.conf
_EOF
# Generate the secret key
openssl rand -hex 32 > /etc/zabbix/zabbix_secret_key.psk
# Enable zabbix-agent2
systemctl enable --now zabbix-agent2.service
# Restart zabbix-agent2
systemctl restart zabbix-agent2.service
Configuring Zabbix-Proxy
# make a copy of the original configuration
cp /etc/zabbix/zabbix_proxy.conf /etc/zabbix/zabbix_proxy.conf.orig
cat << '_EOF' > /etc/zabbix/zabbix_proxy.conf
Server=zabbix.tiozaodolinux.com
#Hostname=Proxy PI5-01
LogFile=/var/log/zabbix/zabbix_proxy.log
EnableRemoteCommands=1
LogRemoteCommands=1
LogFileSize=0
PidFile=/run/zabbix/zabbix_proxy.pid
SocketDir=/run/zabbix
DBName=/tmp/zabbix_proxy.db
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
StartHTTPAgentPollers=2
StartPollers=5
StartSNMPPollers=1
StartPollersUnreachable=2
StartPingers=2
StartDiscoverers=2
ProxyOfflineBuffer=24
ProxyConfigFrequency=60
DataSenderFrequency=1
StartVMwareCollectors=1
VMwareCacheSize=8M
VMwareTimeout=10
ExternalScripts=/usr/lib/zabbix/externalscripts
StatsAllowedIP=127.0.0.1
TLSConnect=psk
TLSAccept=psk
TLSPSKIdentity=PSK PI5-01
TLSPSKFile=/etc/zabbix/zabbix_proxy.psk
_EOF
# Generate the secret key
openssl rand -hex 32 > /etc/zabbix/zabbix_proxy.psk
# Enable zabbix-proxy
systemctl enable --now zabbix-proxy.service
# Restart zabbix-proxy
systemctl restart zabbix-proxy.service
See the logs
tail -f /var/log/zabbix/zabbix_{proxy,agent2}.log | ccze -A
Enable user zabbix like admin
cat << '_EOF_' > /etc/sudoers.d/zabbix-nopasswd
zabbix ALL=(ALL) NOPASSWD: ALL
_EOF_
Templates Zabbix for Raspberry PI

Get the templates-for-raspberry.yaml and import to your Zabbix 7.0 ( Data Colletion > Templates -> Import )
Cloudflare Tunnel
Set up a secure connection between Cloudflare’s global network and your infrastructure.
- See official documentation - https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/
Create Tunnel name

Crete Public Hostname

Install Client Cloudflared
- See official documentation - https://pkg.cloudflare.com/
# Add cloudflare gpg key
mkdir -p --mode=0755 /usr/share/keyrings
curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null
# Add this repo to your apt repositories
# Stable
echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared any main' | sudo tee /etc/apt/sources.list.d/cloudflared.list
# install cloudflared
apt-get update
apt-get -y install cloudflared
# star service cloudflared with YOUR-KEY
#cloudflared service install XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Now is possible acess https://rasp-pi5-01.tiozaodolinux.com, login with user created durant the instalation.
Enable RealVNC
-
See official documentation - https://help.realvnc.com/hc/en-us/articles/360002249917-RealVNC-Connect-and-Raspberry-Pi
-
raspi-config, navigate to Interface Options > VNC and select Yes.
VNC Viewer Connect with PI5

Install RustDesk
- See official documentation - https://rustdesk.com/docs/en/client/
# ARCHITECTURE=`hostnamectl | awk '/Architecture/ { print $2 }'`
ARCHITECTURE=`uname -m`
if [ $ARCHITECTURE == 'arm64' ]; then ARCHITECTURE='aarch64'; fi
LATEST=`curl -sI https://github.com/rustdesk/rustdesk/releases/latest | awk -F'/' '/^location/ {sub("\r","",$NF); print $NF }'`
curl -# -L "https://github.com/rustdesk/rustdesk/releases/download/${LATEST}/rustdesk-${LATEST}-${ARCHITECTURE}.deb" -o rustdesk-${LATEST}-${ARCHITECTURE}.deb
apt-get -y install ./rustdesk-${LATEST}-${ARCHITECTURE}.deb
Add Rustdesk auto-update repo
See this before: https://github.com/xlionjuan/rustdesk-apt-repo-latest
https://github.com/xlionjuan/xlion-repo-archive-keyring/releases/latest
curl -sL https://api.github.com/repos/xlionjuan/xlion-repo-archive-keyring/releases/latest | grep -oP 'https://[^"]+\.deb' | head -1 | xargs -I{} sh -c 'curl -L {} -o /tmp/xlion.deb && sudo dpkg -i /tmp/xlion.deb'
curl -fsSl https://xlionjuan.github.io/rustdesk-apt-repo-latest/latest.sources | sudo tee /etc/apt/sources.list.d/xlion-rustdesk-repo.sources
Checking the installed version
rustdesk --version
1.3.1
Get ID connect
rustdesk --get-id
120792063
Set Unique Password
rustdesk --password PasswordRustdesk@PI-05
Done!
Set Host / Key / API
Change Server ID/Relay to yours in CLI
Working after @lucianostuart's hint. Great boy.
RUSTDESK_CFG="rustdesk.tiozaodolinux.com"
rustdesk --option custom-rendezvous-server $RUSTDESK_CFG
Or configure manually


How create your Rustdesk Server? See Install-Rust-Desk-Server
Rustdesk Connect
Rustdesk Select

Rustdesk Connected at PI4

Rustdesk Connected at PI5

Create Kiosk mode that will start with the system
It will only work if there is at least one Monitor/TV connected to the HDMI output.
Warning - Wayland support is in experimental stage, please use X11 if you require unattended access.
systemctl disable wayvnc.service
systemctl enable vncserver-x11-serviced.serviceraspi-config -> Advanced Options -> Wayland -> X11
Get first user information
export FIRST_USER=`getent passwd 1000 | awk -F'[:]' '{ print $1 }'`
export FIRST_GROUP=`getent group 1000 | awk -F'[:]' '{ print $1 }'`
export FIRST_HOME=`getent passwd 1000 | awk -F'[:]' '{ print $6 }'`
cd $FIRST_HOME
cat << _EOF_ > /etc/sudoers.d/$FIRST_USER-nopasswd
$FIRST_USER ALL=(ALL) NOPASSWD: ALL
_EOF_
Define URLs for the first and second HDMI input
cat << '_EOF_' > HDMI_1.txt
https://wiki.tiozaodolinux.com/
_EOF_
cat << '_EOF_' > HDMI_2.txt
https://www.youtube.com/@TiozaoDoLinux/videos
_EOF_
Script to start chromium in kiosk mode
cat << '_EOF_' > raspberry-kioskmode.sh
#!/bin/bash
#
# Script for Raspberry Pi Quiosque Mode
#
# 17/Jan/2023, jarbas.junior@gmail.com, initial implementation
export FONTCONFIG_PATH=/etc/fonts
# See more em https://askubuntu.com/questions/492033/fontconfig-error-cannot-load-default-config-file
# Basename/Dirname
BASENAME=`basename $0 .sh`
DIRNAME=`dirname $0`
# File log
FILE_LOG="/tmp/$BASENAME.txt"
{
# error: XDG_RUNTIME_DIR is invalid or not set in the environment.
export XDG_RUNTIME_DIR=/run/user/$(id -u)
# Prevent the power manager from turning off or blanking the screen
xset s off -dpms s noblank
#@xset s off disables the screen saver.
#@xset -dpms disables the Display Power Management Signaling.
#@xset s noblank prevents the screen from blanking.
# Hides the mouse from the screen whenever it is idle for more than 0.5 seconds.
unclutter -idle 0.5 -root 2>/dev/null &
# Go to the user's home directory
cd ~
# Show 'pwd'
echo "DEBUG: `pwd`"
# Show 'id'
echo "DEBUG: `id`"
# Show 'what window manager is running'
echo "DEBUG: XDG_SESSION_TYPE=$XDG_SESSION_TYPE"
# Obtem o status das portas HDMI (conected ou disconected)
HDMI_1=`cat /sys/class/drm/card?-HDMI-A-1/status`
HDMI_2=`cat /sys/class/drm/card?-HDMI-A-2/status`
echo "DEBUG: HDMI_1=$HDMI_1 HDMI_2=$HDMI_2"
XRANDR=`xrandr --listmonitors`
echo "DEBUG: XRANDR=$XRANDR"
# Get resolution of HDMI's in format 'XXXXxYYYY'
RES_HDMI_1=`echo "$XRANDR" | gawk '/0: +/ { split($3, X, "/"); split(X[2], Y, "x"); print X[1] "x" Y[2]}'`
RES_HDMI_2=`echo "$XRANDR" | gawk '/1: +/ { split($3, X, "/"); split(X[2], Y, "x"); print X[1] "x" Y[2]}'`
echo "DEBUG: RES_HDMI_1=$RES_HDMI_1 RES_HDMI_2=$RES_HDMI_2"
# Get
HORIZ_HDMI_1=`echo $RES_HDMI_1 | awk -F'[x]' '{ print $1 }'`
HORIZ_HDMI_2=`echo $RES_HDMI_2 | awk -F'[x]' '{ print $1 }'`
echo "DEBUG: HORIZ_HDMI_1=$HORIZ_HDMI_1 HORIZ_HDMI_2=$HORIZ_HDMI_2"
POS_HDMI_1="0,0"
POS_HDMI_2="$HORIZ_HDMI_1,0"
echo "DEBUG: POS_HDMI_1=$POS_HDMI_1 POS_HDMI_2=$POS_HDMI_2"
# If chromium is already running, do nothing.
PIDOF=`pidof chromium`
RESULT=$?
if [ $RESULT -eq 1 ]; then
if [ "$HDMI_1" == "connected" ]; then
urls=`cat HDMI_1.txt`
echo "DEBUG: Open chromium in HDMI_1 with URLs: ${urls}"
# Remove hostname dependencies in chrome
rm -f .config/chromium/HDMI_1/Singleton*
# Don't show "Restore Pages?"
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' .config/chromium/HDMI_1/Default/Preferences 2>/dev/null
chromium --user-data-dir=.config/chromium/HDMI_1 --new-window --noerrdialogs --disable-infobars --window-positon=${POS_HDMI_1} --start-fullscreen ${urls} &
else
echo "DEBUG: HDMI-1 NOT connected"
fi
if [ "$HDMI_2" == "connected" ]; then
urls=`cat HDMI_2.txt`
echo "DEBUG: Open chromium in HDMI_2 with URLs: ${urls}"
# Remove hostname dependencies in chrome
rm -f .config/chromium/HDMI_2/Singleton*
# Don't show "Restore Pages?"
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' .config/chromium/HDMI_2/Default/Preferences 2>/dev/null
chromium --user-data-dir=.config/chromium/HDMI_2 --new-window --noerrdialogs --disable-infobars --window-positon=${POS_HDMI_2} --start-fullscreen ${urls} &
else
echo "DEBUG: HDMI-2 NOT connected"
fi
else
echo "DEBUG: Broswer Chromium is already running - ${PIDOF}"
fi
} 2>&1 | tee $FILE_LOG
_EOF_
chmod +x raspberry-kioskmode.sh
Service kiosk-mode
cat << _EOF_ > raspberry-kioskmode.service
[Unit]
Description=Raspberry Kioskmode
Wants=graphical.target
After=graphical.target
[Service]
Environment=DISPLAY=:0
Environment=XAUTHORITY=${FIRST_HOME}/.Xauthority
Type=simple
ExecStartPre=/bin/sleep 5
ExecStart=${FIRST_HOME}/raspberry-kioskmode.sh
Restart=on-abort
User=${FIRST_USER}
Group=${FIRST_GROUP}
[Install]
WantedBy=graphical.target
_EOF_
Make raspberry-kiosk mode work
# Create simbolic link to raspberry-kioskmode
ln -s ${FIRST_HOME}/raspberry-kioskmode.service /lib/systemd/system/raspberry-kioskmode.service
# Inform the system that there is a new service
systemctl daemon-reload
# Enable raspberry-kiosk mode service
systemctl enable raspberry-kioskmode.service
# Allow files with FISRT_USER
chown ${FIRST_USER}:${FIRST_GROUP} ${FIRST_HOME}/{HDMI*,raspberry-kioskmode*}
A real-world use case
A real-world use case of kiosk mode is being used at the company where I work to display regional bus arrivals and departures.
It works with two TVs positioned in the bus terminals, connected to the Raspberry Pi's HDMI outputs, one for each TV. One TV shows the arrivals and the other shows the departures.
See below that it's possible to connect remotely via Rustdesk and interact on the desktop.

The URLs used in Raspberry Pi are:
-
Departures - https://www.monitora.ms.gov.br/painel-previsao?pontoId=bbe6cc04-f4be-4f66-a3cb-dcdb18942ecb&modalidade=PARTIDAS
Generate an image to clone other Raspberry PI
Save the unallocated part of a disk
┌─[root@rasp-pi5-01]─[~]─[ter out 08 13:10:15]
└──╼ # dd if=/dev/zero of=/zero_file bs=32M status=progress; rm -f /zero_file
58149830656 bytes (58 GB, 54 GiB) copiados, 4225 s, 13,8 MB/s
dd: erro de escrita de '/zero_file': Não há espaço disponível no dispositivo
1734+0 registros de entrada
1733+0 registros de saída
58167361536 bytes (58 GB, 54 GiB) copiados, 4234,25 s, 13,7 MB/s
A cloned system must have a different machine-id than the original
┌─[root@rasp-pi5-01]─[~]─[ter out 08 14:28:37]
└──╼ # rm -f /etc/machine-id
List devices
┌─[jarbelix@jarbelix-Nitro-AN515-44]─[~]─[ter out 08 14:13:22]
└──╼ $ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 111,8G 0 disk
└─sda1 8:1 0 111,8G 0 part /media/jarbelix/FFE9-7623
nvme1n1 259:0 0 931,5G 0 disk
└─nvme1n1p1 259:1 0 931,5G 0 part /home
nvme0n1 259:2 0 238,5G 0 disk
├─nvme0n1p1 259:3 0 286M 0 part /boot/efi
├─nvme0n1p2 259:4 0 16G 0 part [SWAP]
└─nvme0n1p3 259:5 0 222,2G 0 part /
Generate clone file
┌─[jarbelix@jarbelix-Nitro-AN515-44]─[~]─[ter out 08 14:21:40]
└──╼ $ dd if=/dev/sda bs=32M status=progress | gzip -c > rasbpberry-pi-img.gz
17079205888 bytes (17 GB, 16 GiB) copiados, 1177 s, 14,5 MB/s
32849788928 bytes (33 GB, 31 GiB) copiados, 2173 s, 15,1 MB/s
51338280960 bytes (51 GB, 48 GiB) copiados, 3338 s, 15,4 MB/s
63864569856 bytes (64 GB, 59 GiB) copiados, 4126 s, 15,5 MB/s
1903+1 registros de entrada
1903+1 registros de saída
63864569856 bytes (64 GB, 59 GiB) copiados, 4125,86 s, 15,5 MB/s
Writing clone image to micro-sd
┌─[jarbelix@jarbelix-Nitro-AN515-44]─[~]─[ter out 08 14:24:50]
└──╼ $ gzip -cd < rasbpberry-pi-img.gz | sudo dd of=/dev/sda bs=32M status=progress conv=fsync
2780626944 bytes (2,8 GB, 2,6 GiB) copiados, 90 s, 30,9 MB/s
15262777344 bytes (15 GB, 14 GiB) copiados, 1115 s, 13,7 MB/s
63858212864 bytes (64 GB, 59 GiB) copiados, 5159 s, 12,4 MB/s
0+1609418 registros de entrada
0+1609418 registros de saída
63864569856 bytes (64 GB, 59 GiB) copiados, 5159,59 s, 12,4 MB/s
References
Raspberry PI
- How to Install and Use Raspberry Pi Imager - https://linuxhint.com/install_raspberry_pi_imager/
- Install Raspberry Pi OS using Raspberry Pi Imager - https://www.raspberrypi.com/software/
- Operating system images - https://www.raspberrypi.com/software/operating-systems/
- Raspberry Pi Connect (Beta) - https://www.raspberrypi.com/documentation/services/connect.html (Raspberry Pi Connect provides secure access to your Raspberry Pi from anywhere in the world.)
Cloudflare Tunnel
- Raspberry with Cloudflare - https://blog.cloudflare.com/building-a-pet-cam-using-a-raspberry-pi-cloudflare-tunnels-and-teams/
- Connect to SSH in the browser - https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/use-cases/ssh/ssh-browser-rendering/
- Accessing Remotely - https://mhrsntrk.com/blog/raspberry-pi-cloudflare
- Accessing via SSH - https://orth.uk/ssh-over-cloudflare/
Videos
- How To Install ZABBIX Proxy on Raspberry Pi - https://www.youtube.com/watch?v=Ut590nOYqSI (Dmitry Lambert - https://www.youtube.com/@dmitrylambert)
- Set Up SSH via Cloudflare Tunnel - https://www.youtube.com/watch?v=lnw616HiINY&ab_channel=Techdox
- Remote access a Raspberry Pi using a Cloudflare tunnel - https://www.youtube.com/watch?v=Z6b3l1z0N7w&ab_channel=lu4tTech
Kiosk mode
- Raspberry Pi in kiosk mode - https://www.raspberrypi.com/tutorials/how-to-use-a-raspberry-pi-in-kiosk-mode/
- Modo kiosk - https://www.filipeflop.com/blog/modo-quiosque-com-raspberry-pi/
- Change wayland to x11 - https://www.geeks3d.com/20240509/how-to-switch-from-wayland-to-x11-on-raspberry-pi-os-bookworm/
VNC Viewer
- Download VNC Viewer - https://www.realvnc.com/pt/connect/download/viewer/
- Connect wayvnc VNC Server - https://www.claudiokuenzler.com/blog/1385/how-to-connect-raspberry-pi-bookworm-desktop-vnc-wayvnc
Rustdesk
- Last Stable Version - https://github.com/rustdesk/rustdesk/releases/latest
- Install Rustdesk - https://techviewleo.com/install-rustdesk-remote-desktop-on-debian/
- Rustdesk client Linux - https://rustdesk.com/docs/en/self-host/client-deployment/#linux
- Rustdesk Cliente - https://www.reddit.com/r/rustdesk/comments/1dssrrj/how_you_setup_your_clients/?tl=pt-br
- Last Rustdesk - https://github.com/xlionjuan/rustdesk-apt-repo-latest
- RustDesk client generator - https://github.com/bryangerlach/rdgen?tab=readme-ov-file
Cloning Image
- Cloning HD - https://www.baeldung.com/linux/clone-space-in-use-from-disk
- Setps do Clone Micro SD in Linux - https://emteria.com/kb/clone-sd-cards-linux
- Using GZIP - https://ep.gnt.md/index.php/how-to-clone-raspberry-pi-sd-card-on-linux-and-shrink-it-to-actual-size/
Solutions for chromium
- Select Profile no Google chome in CLI - https://support.google.com/chrome/thread/115710399/how-do-i-choose-a-specific-profile-from-the-cli?hl=en
- How to make google chrome work after a host name change - https://askubuntu.com/questions/338052/how-to-make-google-chrome-work-after-a-host-name-change
Various tips
- Automatically keep current version of config files - https://raphaelhertzog.com/2010/09/21/debian-conffile-configuration-file-managed-by-dpkg/
- Base64 Encode/Decode - https://www.baeldung.com/linux/cli-base64-encode-decode
- List architecture - https://developnsolve.com/determining-your-linux-architecture
- List wifi - https://www.baeldung.com/linux/wifi-display-realtime-info
- Using cec-client on a Raspberry Pi - https://gist.github.com/rmtsrc/dc35cd1458cd995631a4f041ab11ff74
- Install Zabbix-Proxy on Raspberry PI - https://bestmonitoringtools.com/install-zabbix-proxy-on-raspberry-pi
PS1 Customization
- Custom Linux Bash Prompt - https://www.considerednormal.com/2015/10/custom-linux-bash-prompt/
- Bash Prompt Generator - https://bash-prompt-generator.org/