Useful networking commands

Copy your ssh key and remove password based ssh access:

scp ~/.ssh/id_rsa.pub user@host:.ssh/authorized_keys
sudo vim /etc/ssh/sshd_config
    PasswordAuthentication no
sudo /etc/init.d/sshd restart

Check if failing ssh accesses:

sudo less /var/log/auth.log | grep "\: Failed password" | less
sudo less /var/log/auth.log.1 | grep "\: Failed password" | less

List all open ports:

netstat -tulpn
# ...or...
ss -tulpn
# ...or...
nmap -sT -O localhost
nmap -sT -O server.example.com

Check latest logins (and if system rebooted):

last | head -50

Scan devices on LAN:

nmap -sP 192.168.1.0/24

Scan all open ports on LAN (fastest way):

nmap -T5 192.168.1.0/24

Scan open ports (and services) on host/IP:

nmap -Pn -v host