From a0dfc133093768aa5be872344e90968ffcec1262 Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Tue, 24 May 2022 16:18:48 +0100 Subject: [PATCH 01/50] Add basic styling to pre element --- main.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.css b/main.css index 9d00b59..9c2a4df 100644 --- a/main.css +++ b/main.css @@ -29,6 +29,12 @@ li > ul{ footer p{ margin: 0; } +pre{ + background-color: #191919; + color: white; + white-space: pre-wrap; + overflow-x: auto; +} /* Special Design */ .tag{ From 5ed8623295f4d02d56a42b3f2dfbdccabc214b68 Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Tue, 24 May 2022 16:21:46 +0100 Subject: [PATCH 02/50] Correct prefix > preface on first blog post --- blog/ive-started-a-blog.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blog/ive-started-a-blog.html b/blog/ive-started-a-blog.html index 716f87a..0c8604e 100644 --- a/blog/ive-started-a-blog.html +++ b/blog/ive-started-a-blog.html @@ -30,7 +30,7 @@
-

To prefix, I am not an author. In fact my skill with the pen was much more proficient when I was a youngling, but alas I have returned to write.

+

To preface, I am not an author. In fact my skill with the pen was much more proficient when I was a youngling, but alas I have returned to write.

Why?

There are many reasons, although I don't believe there even needs to be one. If you want to blog, blog!

To improve my writing skills

From 0bc29fd29c82cc97515564335d9fe55dd0f75ef1 Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Tue, 24 May 2022 17:08:17 +0100 Subject: [PATCH 03/50] Fix trailing > in blog post --- blog/debian-server-setup.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blog/debian-server-setup.html b/blog/debian-server-setup.html index 48f9635..3a4e57a 100644 --- a/blog/debian-server-setup.html +++ b/blog/debian-server-setup.html @@ -38,7 +38,7 @@

This first section will be done on the physical PC, or on the VPS via their website, or SSH'd as root if that's the option given.

Update the OS

-

Even with a fresh install of Debian from the latest ISO, there may be some updates you're missing, and it's a good idea to have these, especially in case they're security updates.

> +

Even with a fresh install of Debian from the latest ISO, there may be some updates you're missing, and it's a good idea to have these, especially in case they're security updates.

 					
 						root$ apt update && apt upgrade	

From 1fba0381a289013887158f721bf66314679a99ad Mon Sep 17 00:00:00 2001
From: Nathan Steel 
Date: Tue, 24 May 2022 17:10:33 +0100
Subject: [PATCH 04/50] Add padding to pre tag

---
 main.css | 1 +
 1 file changed, 1 insertion(+)

diff --git a/main.css b/main.css
index 9c2a4df..2ef34e5 100644
--- a/main.css
+++ b/main.css
@@ -34,6 +34,7 @@ pre{
 	color: white;
 	white-space: pre-wrap;
 	overflow-x: auto;
+	padding: 12px;
 }
 
 /* Special Design */

From b7d1394d0842cff49c3f029598e23e9b1fa5367b Mon Sep 17 00:00:00 2001
From: Nathan Steel 
Date: Wed, 25 May 2022 09:17:55 +0100
Subject: [PATCH 05/50] Make all 
 tags contain no unwanted whitespace

---
 blog/add-domain-to-server.html |  12 ++--
 blog/debian-server-setup.html  | 108 +++++++++++----------------------
 2 files changed, 41 insertions(+), 79 deletions(-)

diff --git a/blog/add-domain-to-server.html b/blog/add-domain-to-server.html
index 5bfc9bb..c46d70b 100644
--- a/blog/add-domain-to-server.html
+++ b/blog/add-domain-to-server.html
@@ -40,16 +40,12 @@
 				

Add the A record

There will likely be many option for adding records, but all we need is to add a singular A record

Find the box that allows you to "Add a new record" and input the below, changing and with your IP address, and domain name

-
-					
-					
-				
+ +

If there are not multiple boxes, but instead a single box to input your record into, this will be what you add instead

-
-					
-					
-				
+ +

Wait for propagation

Now there's a bit of a waiting game, as you need to wait for the new DNS record to propagate (get updated) for all nameservers. This can be anywhere from instantly to 72 hours, but typically takes an hour or two.

diff --git a/blog/debian-server-setup.html b/blog/debian-server-setup.html index 3a4e57a..7acae7b 100644 --- a/blog/debian-server-setup.html +++ b/blog/debian-server-setup.html @@ -39,34 +39,23 @@

Update the OS

Even with a fresh install of Debian from the latest ISO, there may be some updates you're missing, and it's a good idea to have these, especially in case they're security updates.

-
-					
-						root$ apt update && apt upgrade	
-					
-				
+ +
apt update && apt upgrade

Install essential packages

These are packages that are needed for accessing, and controlling the server

-
-					
-						root$ apt install sudo ssh	
-					
-				
+ +
apt install sudo ssh
+

Some useful packages too

-
-					
-						root$ apt install vim htop wget curl tmux	
-					
-				
+
apt install vim htop wget curl tmux

Add a user, and give super user privilleges

You want to avoid using root as much as possible in regular use, so a new user for yourself is a must

-
-					
-						root$ adduser 	
-						root$ usermod -aG sudo 
-					
-				
+ +
adduser 	
+usermod -aG sudo 
+

*replace with the user you want to create, e.g. nathan

(Local server) Set static IP

@@ -74,53 +63,38 @@

Secure ssh

Although this is optional, I recommend it, as SSH (secure shell) will be the primary means of access to the server.

-
-					
-						root$ vim /etc/ssh/sshd_config
-					
-				
+ +
vim /etc/ssh/sshd_config
+

Within the editor you will need to search for PermitRootLogin and set it to no, this prevents ssh as root

Search for Port and set it to a different port to 22, a port over 1024 prevents basic nmap scans, and therefor a lot of bruteforcing, so let's go with 2020 so it's easy to remember

Below the Port line, add a new line with Protocol 2 this enables ssh2, which is more secure

-

(Optional) Comment/Add a # to the beginning of the passwordlogin line. This will prevent sshing to the server from any PC that doesn't have it's SSH key on the server already. I recommend only doing this if your sshkeys are on the server, or you're comfortable adding them.

-
-					
-						root$ systemctl reload sshd
-					
-				
+

(Optional) Comment/Add a # to the beginning of the passwordlogin line. This will prevent sshing to the server from any PC that doesn't have it's SSH key on the server already. I recommend only doing this if your sshkeys are on the server, or you're comfortable adding them.

+ +
systemctl reload sshd
+

This reloads the ssh daemon, and enables all the changes we've made

Setup UFW

UFW (Uncomplicated Firewall) is a simple to use firewall, that can be used to easily open/close ports on your server.

We'll install ufw, deny access inwards to all ports, but allow our server to access any ports outwards. We will then manually allow inwards traffic to the SSH port we set, in this case 2020

-
-					
-						root$ apt install ufw
-						root$ ufw deny incoming
-						root$ ufw allow outgoing
-						root$ ufw allow 2020
-						root$ ufw enable
-					
-				
+ +
apt install ufw
+ufw deny incoming
+ufw allow outgoing
+ufw allow 2020
+ufw enable

If there are any other ports that need to be opened in the future this can be done with:

-
-					
-						root$ ufw allow 
-					
-					or
-					
-						root$ sudo ufw allow 
-					
-				
+
ufw allow 
+

or

+
sudo ufw allow 

Set hostname

Setting the name for a server is an important step, but the name doesn't need to be serious

-
-					
-						root$ vim /etc/hosts
-						root$ vim /etc/hostname
-					
-				
+ +
vim /etc/hosts
+vim /etc/hostname
+

Within both of these files the hostname should be changed to the same thing

@@ -129,25 +103,17 @@

This next section can be done via a terminal, or an SSH client e.g. PuTTY for Windowss. For the sake of the guide, this assume you're using a Unix terminal

Create an SSH key

We'll create an ed25519 ssh-key, as it's more secure, and performant than the defaultrsa

-
-					
-						$ ssh-keygen -t ed25519
-					
-				
+
ssh-keygen -t ed25519
+

SSH into the server

This is a two part section, and I recommend using this every time you SSH into a server from a new PC

-
-					
-						$ ssh @ -p 2020
-					
-				
+
ssh @ -p 2020
+

This will likely display a message asking to verify the key for the server. This is to prevent man-in-the-middle attacks, so I reccommend verifying this whenever asked.

To check the key for the server, you need to run this command on the server.

-
-					
-						$ ssh-keygen -l -f /etc/ssh/ssh_host__key.pub	
-					
-				
+ +
ssh-keygen -l -f /etc/ssh/ssh_host__key.pub
+

Replace with the key the message is asking about. Then if key the server shows matches that on your PC you are SSHing from, type yes and hit enter

TODO:(Optional) Fail2Ban

From 2a0afcb173b64b8461d3d027982ddfaee2b8dfec Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Thu, 26 May 2022 10:29:46 +0100 Subject: [PATCH 06/50] Rename debian-server-setup to initial-server-setup This is in case I wish to add a freeBSD, centOS, etc. section without needing to rename and 301 --- blog/guide-to-server-hosting.html | 2 +- blog/index.html | 2 +- .../{debian-server-setup.html => initial-server-setup.html} | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) rename blog/{debian-server-setup.html => initial-server-setup.html} (97%) diff --git a/blog/guide-to-server-hosting.html b/blog/guide-to-server-hosting.html index c8104f1..c3303c9 100644 --- a/blog/guide-to-server-hosting.html +++ b/blog/guide-to-server-hosting.html @@ -36,7 +36,7 @@

Basic Server setup

diff --git a/blog/index.html b/blog/index.html index 21e1473..e853ea8 100644 --- a/blog/index.html +++ b/blog/index.html @@ -39,7 +39,7 @@

2022

diff --git a/blog/debian-server-setup.html b/blog/initial-server-setup.html similarity index 97% rename from blog/debian-server-setup.html rename to blog/initial-server-setup.html index 7acae7b..a24336c 100644 --- a/blog/debian-server-setup.html +++ b/blog/initial-server-setup.html @@ -3,19 +3,19 @@ - + - Debian Server Setup + Initial Server Setup
-

Debian Server Setup

+

Initial Server Setup