Sudo user mountdoom has previously been created on baggins; see User management to proceed.
From a terminal, connect to the Pi, which ip is 192.168.0.10
BASH
ssh mountdoom@192.168.0.10
Enforce connection security
Enable SSH key auth
Disable remote password logins for all users
BASH
/boot/dietpi/func/dietpi-set_software disable_ssh_password_logins 1
Change dropbear SSH port
BASH
sudo nano /etc/default/dropbear
Adapt line to desired port
INI
# The TCP port that Dropbear listens on
DROPBEAR_PORT=2022
After reboot / reload, connect with
BASH
ssh -p 2022 mordor
Or change alias in
.ssh/config
Host mordor
HostName remote.ip.address
Port 2022
User mountdoom
IdentityFile ~/.ssh/mordor
And connect with
BASH
ssh mordor
Firewall
BASH
sudo apt update
sudo apt install ufw
Add an exception for the current connection
BASH
sudo ufw allow 2022/tcp comment 'SSH custom'
Activate UFW
BASH
sudo ufw enable
Optional: restrict SSH connection to one LAN ip
In this example, the local client ip we're connecting from is 192.168.0.20
BASH
sudo ufw allow from 192.168.0.20 to any port 2022 proto tcp comment 'SSH dedicated'
Check line numbers of unnecessary rules
BASH
sudo ufw status numbered
Status: active
To Action From
-- ------ ----
[ 1] 2022/tcp ALLOW IN Anywhere # SSH custom
[ 2] 2022/tcp ALLOW IN 192.168.0.20 # SSH dedicated
[ 3] 2022/tcp (v6) ALLOW IN Anywhere (v6) # SSH custom
Remove them with
BASH
sudo ufw delete 3
sudo ufw delete 1
And reload UFW
BASH
sudo ufw reload