vps_-_debian
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
vps_-_debian [2021/04/02 09:09] – [Firewall Setup] hc9 | vps_-_debian [2021/04/02 18:51] (current) – [Networking] hc9 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{: | ||
+ | |||
+ | ====== Debian on SDF VPS ====== | ||
+ | |||
+ | ===== Basics ===== | ||
+ | |||
+ | The root user on a fresh Debian VPS has the default password " | ||
+ | |||
+ | After logging in to your VPS for the first time, please change this password to something more secure. Type '' | ||
+ | |||
+ | It is a good habit to create a regular user account for working, using '' | ||
+ | |||
+ | useradd -m < | ||
+ | |||
+ | This user will be able to perform administrative tasks by runing '' | ||
+ | |||
+ | ===== Set Your Timezone ===== | ||
+ | |||
+ | dpkg-reconfigure tzdata | ||
+ | |||
+ | ===== Networking ===== | ||
+ | |||
+ | In your control panel at vps.sdf.org, | ||
+ | |||
+ | Start your server, and log in via the console. (default= root: | ||
+ | |||
+ | Open / | ||
+ | |||
+ | <file config / | ||
+ | auto eth0 | ||
+ | iface eth0 inet static | ||
+ | address YOUR_IP | ||
+ | netmask 255.255.255.0 | ||
+ | network 205.166.94.0 | ||
+ | broadcast 205.166.94.255 | ||
+ | gateway 205.166.94.1 | ||
+ | dns-nameservers 205.166.94.20 | ||
+ | </ | ||
+ | |||
+ | //Note: For VPS installations of Debian 8.4 (jesse) on VPS3, please omit the above dns-nameservers line from the interfaces file, and instead add this line to // | ||
+ | |||
+ | <file config / | ||
+ | nameserver 205.166.94.20 | ||
+ | </ | ||
+ | |||
+ | Add this to /etc/hosts: | ||
+ | |||
+ | <file config / | ||
+ | YOUR_IP YOUR_HOSTNAME.sdf.org YOUR_HOSTNAME | ||
+ | </ | ||
+ | |||
+ | Change / | ||
+ | |||
+ | <file config / | ||
+ | YOUR_HOSTNAME | ||
+ | </ | ||
+ | |||
+ | Run/Type: | ||
+ | |||
+ | / | ||
+ | |||
+ | ===== Setting up SSH ===== | ||
+ | |||
+ | You may wish to add ssh access to your VPS. It is **// | ||
+ | |||
+ | ==== Install SSH ==== | ||
+ | |||
+ | Run/Type: | ||
+ | |||
+ | apt-get install openssh-server | ||
+ | |||
+ | ==== Disable root Login ==== | ||
+ | |||
+ | Edit /// | ||
+ | |||
+ | <file config / | ||
+ | PermitRootLogin yes | ||
+ | </ | ||
+ | |||
+ | To: | ||
+ | |||
+ | <file config / | ||
+ | PermitRootLogin no | ||
+ | </ | ||
+ | |||
+ | Now restart sshd by running/ | ||
+ | |||
+ | / | ||
+ | |||
+ | You can now test ssh by running '' | ||
+ | |||
+ | ===== Package Management ===== | ||
+ | |||
+ | Refer to the following article to see how to clean up (remove packages) from your VPS: | ||
+ | |||
+ | * [[http:// | ||
+ | |||
+ | ===== Firewall Setup ===== | ||
+ | |||
+ | Disable IPv6: | ||
+ | |||
+ | # echo " | ||
+ | |||
+ | Edit rules: | ||
+ | |||
+ | # vi / | ||
+ | |||
+ | <file config / | ||
+ | *filter | ||
+ | |||
+ | -A INPUT -i lo -j ACCEPT | ||
+ | -A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT | ||
+ | |||
+ | -A OUTPUT -j ACCEPT | ||
+ | -A INPUT -m state --state ESTABLISHED, | ||
+ | |||
+ | -A INPUT -p tcp --dport 80 -j ACCEPT | ||
+ | -A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT | ||
+ | |||
+ | -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT | ||
+ | |||
+ | -A INPUT -m limit --limit 5/min -j LOG --log-prefix " | ||
+ | |||
+ | -A INPUT -j REJECT | ||
+ | -A FORWARD -j REJECT | ||
+ | |||
+ | COMMIT | ||
+ | </ | ||
+ | |||
+ | Load rules (now): | ||
+ | |||
+ | <file config now> | ||
+ | # iptables -F | ||
+ | # iptables-restore < / | ||
+ | </ | ||
+ | |||
+ | Load rules (boot): | ||
+ | |||
+ | <file config boot> | ||
+ | # vi / | ||
+ | |||
+ | #!/bin/sh | ||
+ | / | ||
+ | |||
+ | # chmod 755 / | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Software and Distribution Updating ===== | ||
+ | |||
+ | To update your system, run the following commands: | ||
+ | |||
+ | * apt-get update < | ||
+ | </ | ||
+ | * apt-get dist-upgrade -y < | ||
+ | </ | ||
+ | |||
+ | ===== Reducing Memory Usage ===== | ||
+ | |||
+ | If you are using a 128MB slice, it's a good idea to reduce the memory usage of some processes or even disable them. | ||
+ | |||
+ | ==== cron and at ==== | ||
+ | |||
+ | You might not need one or both of those, so you can deactivate them with | ||
+ | |||
+ | <file config cron and at> | ||
+ | # update-rc.d -f atd remove | ||
+ | # update-rc.d -f cron remove | ||
+ | </ | ||
+ | |||
+ | This frees up ca. 7MB (if both are deactivated). | ||
+ | |||
+ | ==== getty / virtual terminals ==== | ||
+ | |||
+ | This being a virtual system, you won't need getty on tty1-6. In order to eliminate them, edit / | ||
+ | |||
+ | <file config / | ||
+ | co: | ||
+ | |||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | </ | ||
+ | |||
+ | You need to keep the line with hvc0 so you can attach a serial console from vps.sdf.org to your vps. This frees up ca. 10MB. | ||
+ | |||
+ | ==== rsyslogd ==== | ||
+ | |||
+ | rsyslogd eats a lot of memory by default (26MB on my vps) which can be reduced by the usage of ulimit. Edit / | ||
+ | |||
+ | <file config / | ||
+ | ulimit -s 256 | ||
+ | </ | ||
+ | |||
+ | Example: | ||
+ | |||
+ | <file config / | ||
+ | case " | ||
+ | start) | ||
+ | ulimit -s 256 | ||
+ | log_daemon_msg " | ||
+ | create_xconsole | ||
+ | do_start | ||
+ | case " | ||
+ | 0) sendsigs_omit | ||
+ | | ||
+ | 1) log_progress_msg " | ||
+ | | ||
+ | *) log_end_msg 1 ;; | ||
+ | esac | ||
+ | ;; | ||
+ | </ | ||
+ | |||
+ | This frees up about 23MB. | ||
+ | |||
+ | ==== portmap ==== | ||
+ | |||
+ | I don't need portmap, so i removed it completely: | ||
+ | |||
+ | apt-get remove --purge portmap | ||
+ | | ||
+ | ==== openssh vs. dropbear ==== | ||
+ | |||
+ | If you dont need all the extra features openssh has compared to dropbear, you can reduce memory consumption from 23MB to 5MB while being connected with 1 non-root user to the system by replacing openssh with dropbear. | ||
+ | |||
+ | apt-get install dropbear | ||
+ | | ||
+ | Edit / | ||
+ | |||
+ | < | ||
+ | # disabled because OpenSSH is installed | ||
+ | # change to NO_START=0 to enable Dropbear | ||
+ | NO_START=0 | ||
+ | |||
+ | # the TCP port that Dropbear listens on | ||
+ | DROPBEAR_PORT=22 | ||
+ | |||
+ | # any additional arguments for Dropbear | ||
+ | DROPBEAR_EXTRA_ARGS=" | ||
+ | |||
+ | # specify an optional banner file containing a message to be | ||
+ | # sent to clients before they connect, such as "/ | ||
+ | DROPBEAR_BANNER="" | ||
+ | |||
+ | # RSA hostkey file (default: / | ||
+ | # | ||
+ | |||
+ | # DSS hostkey file (default: / | ||
+ | # | ||
+ | |||
+ | # Receive window size - this is a tradeoff between memory and | ||
+ | # network performance | ||
+ | DROPBEAR_RECEIVE_WINDOW=65536 | ||
+ | </ | ||
+ | |||
+ | Afterwards, you can deactivate openssh with | ||
+ | |||
+ | update-rc.d ssh remove | ||
+ | |||
+ | or uninstall it: | ||
+ | |||
+ | apt-get remove openssh-server | ||
+ | |||
+ | ---- | ||
+ | $Id: VPS_Debian.html, | ||
+ | |||