Blog 
August 18th, 2026
Basic setup for DigitalOcean VPS
Basic setup for DigitalOcean VPS
Sodara Sou
Create another user
Since you want to login as this user then switch to root via su , we have to create another user with:
sudo adduser username
Edit sshd_config: new port + block root login
sudo nano /etc/ssh/sshd_config
Set Port 2222 (or your chosen port) and PermitRootLogin no, removing any leading #. Save and exit, then validate with:
sudo sshd -t
no output = valid
Disable ssh.socket
Ubuntu defaults to socket-based SSH activation, which ignores your Port setting entirely. Disable it so sshd runs standalone and actually respects sshd_config:
sudo systemctl stop ssh.socket
sudo systemctl disable ssh.socket
Then
sudo systemctl enable ssh.service
sudo systemctl start ssh.service
Verify only the new port is listening
sudo ss -tlnp | grep ssh
Should show only your new port, one PID
Lock down the firewall — allow ports before enabling
Allow what you need:
sudo ufw allow 2222/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
Then
sudo ufw default deny incoming
sudo ufw default allow outgoing
Then enable the ufw:
sudo ufw enable
Check the ufw status and ports:
sudo ufw status
Test everything from a brand new terminal
From a completely fresh terminal:
ssh -p 2222 username@server_ip
Should work, then switch to root via su:
su -
Confirm these all fail:
ssh root@server_ip
ssh -p 2222 root@server_ip
ssh username@server_ip
That it!