sudo aptitude update && sudo aptitude safe-upgrade
adduser <your username>
usermod -a -G sudo <your username>
ssh-keygen -t rsa -C "<your username>@<your username>.org"
scp ~/.ssh/id_rsa.pub newuser@<server-ip>:~/
mkdir .ssh
mv id_rsa.pub .ssh/authorized_keys
chown -R <your username>:<your username> .ssh
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
sudo vim /etc/ssh/sshd_config
Set "Port 869"
Set "PermitRootLogin no"
sudo service ssh restart
ssh -p 869 newuser@<server-ip>
sudo aptitude install fail2ban
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo vim /etc/fail2ban/jail.local
Set "enabled" to "true" in [ssh-ddos] section
Set "port" to "869" in [ssh] and [ssh-ddos] sections
sudo service fail2ban restart
sudo iptables -L
sudo vim /etc/iptables.firewall.rules
Add to file:
# file: /etc/iptables.firewall.rules
*filter
# Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
# Accept all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow all outbound traffic - you can modify this to only allow certain traffic
-A OUTPUT -j ACCEPT
# Allow HTTP and HTTPS connections from anywhere (the normal ports for websites and SSL).
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT
# Allow ports for testing
-A INPUT -p tcp --dport 8080:8090 -j ACCEPT
# Allow ports for MOSH (mobile shell)
-A INPUT -p udp --dport 60000:61000 -j ACCEPT
# Allow SSH connections
# The -dport number should be the same port number you set in sshd_config
-A INPUT -p tcp -m state --state NEW --dport 869 -j ACCEPT
# Allow ping
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
# Log iptables denied calls
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
# Reject all other inbound - default deny unless explicitly allowed policy
-A INPUT -j REJECT
-A FORWARD -j REJECT
COMMIT
sudo iptables-restore < /etc/iptables.firewall.rules
sudo iptables -L
sudo vim /etc/network/if-pre-up.d/firewall
#!/bin/sh
/sbin/iptables-restore < /etc/iptables.firewall.rules
sudo chmod +x /etc/network/if-pre-up.d/firewall
sudo aptitude install sendmail
sudo vim /etc/sudoers.d/my_sudoers
Defaults mail_always
Defaults mailto="user@email"
sudo chmod 0440 /etc/sudoers.d/my_sudoers
FIXME: Time zone - related to server lozation? tzdata