Protecting your SOHO network


Check Network Vulnerability with OpenVAS

  1. Check your public ip address, via searching "what is my ip" in Google.
  2. Go to https://pentest-tools.com/network-vulnerability-scanning/network-security-scanner-online-openvas, and enter your ip.
  3. If there are no opened ports, it should be fine.

Scan by nmap


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
    

Wifi Router settings

Server update


sudo apt update # manual
sudo apt dist-upgrade # manual
sudo apt install unattended-upgrades # auto
sudo dpkg-reconfigure --priority=low unattended-upgrades
    

Create user in sudo group


sudo adduser username # then password, edit profile question
sudo usermod -aG sudo username
    

Public and Private Key to replace password

graph LR A[Private Key] --> B[Public Key]; subgraph "Laptop"; A end; subgraph "Server"; B end;
  1. In Linux server, create a folder to store public key,
  2. 
    mkdir ~/.ssh && chmod 700 ~/.ssh
        
  3. In client, create a key pair (public and private).
  4. 
    ssh-keygen -b 4096 # store in default, id_rsa can be overwritten. Avoid overwriting, can skip passphrase
    # private: id_rsa, public: id_rsa.pub
        
  5. Copy the public key to the server side.
  6. 
    # Windows 
    scp $env:USERPROFILE/.ssh/id_rsa.pub username@ip
    # Linux
    scp ~/.ssh/id_rsa.pub username@ip
    ssh-copy-id username@ip
        

Change ssh server settings


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.

Server firewall settings

  1. Check the ports.
  2. 
    sudo ss -tupln
        
  3. Get uncomplicated firewall (ufw) working.
  4. 
    sudo ufw status
    sudo ufw allow port # for example, 80/tcp
    sudo ufw enable # y
        
  5. Edit firewall rules in /etc/ufw/before.rules.
  6. 
    # 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

References