EP 01 Provision, harden, and own your first VPS
4 sections
// SSH Hardening
Connect to your VPS for the first time
$ ssh root@YOUR_SERVER_IP
Generate an SSH key pair (run on your local machine)
$ ssh-keygen -t ed25519 -C "[email protected]"
Copy your public key to the server
$ ssh-copy-id -i ~/.ssh/id_ed25519.pub root@YOUR_SERVER_IP
Edit SSH daemon config
# nano /etc/ssh/sshd_config
Key sshd_config settings to change
Port 2222 # change from 22 PermitRootLogin prohibit-password PasswordAuthentication no PubkeyAuthentication yes X11Forwarding no
Restart SSH after changes
# systemctl restart sshd
Keep your existing session open and test the new port in a second terminal before closing.
// Virtualmin Install
Download the Virtualmin install script
# wget -O virtualmin-install.sh https://software.virtualmin.com/gpl/scripts/virtualmin-install.sh
Run the installer
# bash virtualmin-install.sh --minimal
--minimal skips mail and DNS components you can add later. Safer starting point.
// Firewalld Port Lockdown
Check firewalld status
# systemctl status firewalld
List all active rules
# firewall-cmd --list-all
Lock Virtualmin (10000) and Usermin (20000) to your home IP
# firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="YOUR_HOME_IP/32" port port="10000" protocol="tcp" accept' # firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="YOUR_HOME_IP/32" port port="20000" protocol="tcp" accept' # firewall-cmd --reload
Replace YOUR_HOME_IP with your actual IP. Find it with: curl ifconfig.me
Open your custom SSH port in firewalld
# firewall-cmd --permanent --add-port=2222/tcp # firewall-cmd --reload
// Initial System Setup
Set your server hostname
# hostnamectl set-hostname your.hostname.com
Update all packages (AlmaLinux / RHEL)
# dnf update -y
Check OS version
# cat /etc/os-release
Check server uptime and load
# uptime
REF General VPS Reference
6 sections
// File System Navigation
Where am I / what's here
# pwd # print working directory # ls -la # list all files with permissions # ls -lah # same but human-readable sizes
Find files
# find / -name "filename.txt" 2>/dev/null # find /etc -name "*.conf"
Disk usage
# df -h # disk free, human-readable # du -sh /var/log # size of a specific directory # du -sh /* # size of every root-level dir
// Processes and System
What's running / eating resources
# top # live process view (q to quit) # htop # better top (may need: dnf install htop) # ps aux # all running processes # ps aux | grep nginx # filter for a specific process
Memory usage
# free -h # RAM and swap usage
Kill a process
# kill PID # graceful stop # kill -9 PID # force kill # pkill processname # kill by name
// Systemd Services
Start / stop / restart / status
# systemctl start nginx # systemctl stop nginx # systemctl restart nginx # systemctl status nginx
Enable / disable on boot
# systemctl enable nginx # start on boot # systemctl disable nginx # don't start on boot
View service logs
# journalctl -u nginx # all logs for a service # journalctl -u nginx -f # follow live # journalctl -u nginx --since "1 hour ago"
// Networking
Check open ports and listening services
# ss -tlnp # TCP listening ports with process # ss -tulnp # TCP + UDP # netstat -tlnp # older alternative
Check your public IP
# curl ifconfig.me # curl icanhazip.com
DNS lookup
# dig yourdomain.com # dig yourdomain.com MX # mail records # dig yourdomain.com TXT # SPF / DMARC / DKIM # nslookup yourdomain.com
Test connectivity
# ping -c 4 google.com # traceroute google.com # curl -I https://yourdomain.com # check HTTP headers
// Log Files
Common log locations
# Auth / SSH attempts # tail -f /var/log/secure # Apache # tail -f /var/log/httpd/error_log # tail -f /var/log/httpd/access_log # Postfix mail # tail -f /var/log/maillog # General system messages # tail -f /var/log/messages
Search logs for a keyword
# grep "Failed password" /var/log/secure # grep "Failed password" /var/log/secure | wc -l # count hits
// File Editing and Permissions
Edit a file
# nano /path/to/file # beginner-friendly # vi /path/to/file # always available, :wq to save+quit
File permissions
# chmod 644 file.txt # rw-r--r-- # chmod 755 script.sh # rwxr-xr-x (executable) # chown user:group file # change owner # chown -R apache:apache /var/www/html # recursive
Copy, move, delete
# cp file.txt /backup/file.txt # cp -r /dir /backup/dir # recursive copy # mv file.txt newname.txt # move or rename # rm file.txt # rm -rf /dir # recursive force - no undo
EP 02 Coming soon
--