nmap -sT public_ip # T: TCP scan gives you a list of opened ports
nmap --script vuln public_ip # gives you a list of vulnerability
nmap -sT -p port public_ip
sudo apt update # manual
sudo apt dist-upgrade # manual
sudo apt install unattended-upgrades # auto
sudo dpkg-reconfigure --priority=low unattended-upgrades
sudo adduser username # then password, edit profile question
sudo usermod -aG sudo username
mkdir ~/.ssh && chmod 700 ~/.ssh
ssh-keygen -b 4096 # store in default, id_rsa can be overwritten. Avoid overwriting, can skip passphrase
# private: id_rsa, public: id_rsa.pub
# Windows
scp $env:USERPROFILE/.ssh/id_rsa.pub username@ip
# Linux
scp ~/.ssh/id_rsa.pub username@ip
ssh-copy-id username@ip
Port xxxx # not 22
AddressFamily inet # just for ipv4
PermitRootLogin no
PasswordAuthentication no
Then restart by sudo systemctl restart sshd
.
Next time, ssh with ssh username@ip -p port
.
sudo ss -tupln
sudo ufw status
sudo ufw allow port # for example, 80/tcp
sudo ufw enable # y
/etc/ufw/before.rules
.
# Add this line to
...
# ok icmp codes for INPUT
-A ufw-before-input -p icmp --icmp-type echo-request -j DROP
...
This avoids pinging me. sudo ufw reload && sudo reboot