Table of Contents
Change network to static IP
-
Edit the
network/interfacefile, make sure to be root beforehand:nano /etc/network/interfaces -
Add the following lines (replace address, netmask and gateway with your own values):
iface eth0 inet static address 192.168.1.200 netmask 255.255.255.0 gateway 192.168.1.1 -
Reboot the computer:
systemctl reboot
SSH Pubkey
Use a private/public key pair to connect to another computer using SSH. We’ll also see how to disable the connection with a username/password.
-
Generate the key pair on your local computer:
ssh-keygen -t rsa -b 4096 -
Copy the public key (the one ending with
.pub) to the remote server. Preferably to the home directory of the user you want to use to connect. -
Add key to authorized keys:
mkdir ~/.ssh cat ~/id_rsa.pub >> ~/.ssh/authorized_keys rm id_rsa.pub chmod 700 ~/.ssh/ chmod 600 ~/.ssh/*
(Optional) Disable connection with username/password
-
Modify the file
/etc/ssh/sshd_config:nano /etc/ssh/sshd_config -
Set the following lines:
PasswordAuthentication no ChallengeResponseAuthentication no UsePAM no -
Restart the SSH server:
service ssh restart
Storage
Check disk space and usage
You can check how much space is available on each volume using:
df -hYou can quickly get the size of a folder with:
du -hsYou can explore a three view of a folder/disk using ncdu:
apt-get install ncdu
ncduIncrease disk space
Increase the disk space of the server’s storage. Source: How to Resize a Live Filesystem on Linux
ONLY follow these steps if it’s the only partition on the disk. If there is a swap partition, you need to remove it first.
-
Check list of disks:
fdisk --l -
Find the disk you want to increase the size of (e.g:
/dev/xvda) and enter:fdisk /dev/xvda -
Press
pto list the partitions. Make sure there’s only one. -
If so, press
d, the partition has been deleted. -
Press
nto create a new partition. -
Follow what’s asked on screen. You probably want Partition type to be
p, Partition number to be1. -
Make sure to match the First sector from whatever it was before (typically
2048). -
Last sector is the highest possible by default, to take the entire disk space.
-
It will find a ext4 signature, DO NOT REMOVE IT, so press
n. -
Now press
pagain to list the partitions. Compare the listing with the one you did before you deleted the partition. Make sure the columns Boot, Start, Id, and Type are the same.- If Boot isn’t the same, press
a.
- If Boot isn’t the same, press
-
When absolutely sure, press
w. -
Now extends the partition filesystem using:
resize2fs /dev/xvda1 -
Check your changes using:
df -h
Mount new disk
Intialize and mount a brand new empty disk to the server. We’ll use the /data mount point and the ext4 filesystem.
-
Check the connected disk using:
fdisk -l -
Find the right one (e.g:
/dev/xvdb) and do:cfdisk /dev/xvdbSelect
GPT, selectnew, selectwrite, selectquit -
Now the new partition should show up in fdisk:
fdisk -l /dev/xvdb -
Find the partition (should be something like
/dev/xvdb1).
Initialize the filesystem:mkfs.ext4 /dev/xvdb1 -
Find the new partition UUID with:
blkid /dev/xvdb1 -
Add the following line to the
/etc/fstab(replace the UUID with the one you found at step 5 and path if necessary):UUID=a43c3374-7e1a-49a3-b7e8-877827ddb7ed /data ext4 rw 0 0 -
Mount the disks using:
mount -a
From there on, the disk will be mounted automatically at boot.
Setup SMTP server
Setup a SMTP server to send emails. Source: StackOverflow
-
Change to your mail config directory:
cd /etc/mail -
Make a auth subdirectory:
mkdir auth chmod 700 auth -
Create a file with your auth information to the smtp server:
cd auth nano client-info -
In the file, put the following, matching up to your smtp server:
AuthInfo:your.isp.net "U:root" "I:user" "P:password" -
Generate the Authentication database, make both files readable only by root:
makemap hash client-info < client-info chmod 600 client-info cd .. -
Add the following lines to sendmail.mc (
ris:ErrorWarningthe first single quote for each string should be changed to a backtick):define(`SMART_HOST',`your.isp.net')dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl FEATURE(`authinfo',`hash /etc/mail/auth/client-info')dnl -
Lastly, run:
sudo sendmailconfig
Cloudflared
Setup a Cloudflared tunnel to access your server from the internet.
-
Install the latest version of Cloudflared:
wget -q https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb dpkg -i cloudflared-linux-amd64.deb cd /root/.cloudflared -
Login to Cloudflared:
cloudflared tunnel loginThis will open a web browser. Select the domain you want to add Argo to.
-
Generate and download a Cloudflare certificate for the domain (see: Cloudflare Docs):
mv cert.pem cert.pem.[domain name] cloudflared tunnel --origincert cert.pem.[domain name] create [tunnel name] cloudflared tunnel --origincert cert.pem.[domain name] list cloudflared tunnel --origincert cert.pem.[domain] route dns [tunnel name] [sub.domain] -
Create a configuration file for the tunnel:
nano /etc/cloudflared/[domain].ymlPaste the following content:
tunnel: [domain name] credentials-file: /root/.cloudflared/[json file that was create].json logfile: /var/log/cloudflared.[domain name].log ingress: - hostname: [domain] originRequest: originServerName: [domain] service: https://localhost - hostname: "*.[domain]" originRequest: originServerName: [domain] service: https://localhost - service: http_status:404 -
Enable and start the service:
systemctl enable cloudflared@[domain name] systemctl start cloudflared@[domain name]