Skip to content

Setup new server

bestchanges edited this page Apr 28, 2018 · 9 revisions

Install

ssh as root:

apt-get update
apt-get upgrade

useradd user
su - user
mkdir .ssh
cat > .ssh/authorized_keys
<paste key>

Swap

Some VPS disable adding swap... Ugh..

follow: https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-16-04

To create 1Gb swap:

sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
ls -lh /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show

Make permanent:

vi /etc/fstab
add:
/swapfile none swap sw 0 0

Set swapness to lower

sudo cat /proc/sys/vm/swappiness
sudo sysctl vm.swappiness=10
sudo cat /proc/sys/vm/swappiness
sudo nano /etc/sysctl.conf
add:
vm.swappiness=10

Config

set hostname

sudo vi /etc/hostname 
sudo vi /etc/hosts
127.0.1.1     new-hostname
sudo service hostname start

Secure

sudo apt-get install denyhosts fail2ban 
sudo service denyhosts restart
sudo service fail2ban restart
vi  /etc/ssh/sshd_config
comment out password auth
#PasswordAuthentication yes

Firewall

follow: https://www.digitalocean.com/community/tutorials/how-to-setup-a-firewall-with-ufw-on-an-ubuntu-and-debian-cloud-server

Tuning

Increase number of files

from: https://easyengine.io/tutorials/linux/increase-open-files-limit/

Open file:

sudo vi /etc/security/limits.conf

Paste following towards end:

*         hard    nofile      500000
*         soft    nofile      500000
root      hard    nofile      500000
root      soft    nofile      500000

Monitoring

use component https://github.com/bestminer12/bm-glances

Performance

from: https://www.thomas-krenn.com/en/wiki/Linux_I/O_Performance_Tests_using_dd


Store stat and config: https://docs.google.com/spreadsheets/d/1IIo3srX3ZzqnDVG_WvE7zugzOo5qTdxLmfRvRkn8lvg/edit#gid=0

Clone this wiki locally