diff --git a/README.md b/README.md index 45a1814..b062b99 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,18 @@ semantic, accessable, and snappy. ## Release Notes +### v0.10.0 +- Tweaks to blog articles, and pages + +### v0.9.0 + +- Accessibility changes +- Change colours +- Increase font size/whitespace +- Add "skip to content" button +- Redesign burger navigation +[Patch notes](https://aney.co.uk/blog/release-0.9.0) + ### v0.8.0 - Add about page diff --git a/about.html b/about.html index 331c5cb..47f6f78 100644 --- a/about.html +++ b/about.html @@ -38,7 +38,7 @@

I set this website up as a means to share information to educate, and help people, as well as to easily point people to my answers for common questions.

What do you do?

-

I'm currently employed as a web developer, and I enjoy it to an extent. I love solving problems, optimising sites, and creating designs/experiences, but building the guts, not so much.

+

I'm currently taking some time away from work, but looking for places I believe I'd be a good fit. I love solving problems, optimising sites, and creating designs/experiences, so I'm kind of a developer at heart.

Outside of work I practise minimalism, frugalism (to an extent), and work towards Financial Independance (FI/RE). I also love the idea of OneBagging, self-sufficiency, and travelling, so these are things I'm trying to work towards.

What else do you do?

diff --git a/guides/add-domain-to-server.html b/guides/add-domain-to-server.html index 7e1cc0a..cbf4963 100644 --- a/guides/add-domain-to-server.html +++ b/guides/add-domain-to-server.html @@ -4,7 +4,6 @@ - @@ -33,28 +32,26 @@
-

To avoid needing to remember an IP, this guide will help to link your domain name to your server.

+

To avoid needing to remember an IP, this guide will help to link your domain name to your server. It assumes you have already attained a domain name.

+

Login to your domain name registrar

Login to the registrar, and select the domain name you want to point at your server.

Find the section for DNS

-

The domain name should have a section named, "DNS", "Custom DNS records", or something similar to this. Find, and open it, there should be a bunch of boxes and an option to add a new record

+

The domain name should have a section named, "DNS", "Custom DNS records", or something similar to this. Find, and open it, there should be a bunch of boxes and an option to add a new record.

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

- -
+

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

- -
+
<DOMAIN> A 86400 <IP>

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.

Check your domain has propagated

-

Pinging the domain name will let you know when the IP has propagated, as when the ping command shows your IP, you're all set

+

Pinging the domain name will let you know when the IP has propagated, as when the ping command shows your IP, you're all set.

+ +
ping -c 3 domainname.com
diff --git a/guides/add-php-to-nginx.html b/guides/add-php-to-nginx.html index 456da21..f2fd409 100644 --- a/guides/add-php-to-nginx.html +++ b/guides/add-php-to-nginx.html @@ -36,42 +36,38 @@

PHP is one of the highest used programming languages for websites, and it allows you to add practically any functionality you'd ever want to your sites.

Install

-
sudo apt install php-fpm php-mysql
- -

Um, I forgor

-
sudo nano /etc/php//fpm/php.ini
-

Comment the cgi.fix_pathinfo line, to look like below

-
#set cgi.fix_pathinfo = 0
+
sudo apt install php-fpm
+

If you want to work with mysql, then you also need to install php-mysql.

Add to Website's NGINX conf

-

For each website you want to use php, you'll need to edit the confige file

+

For each website you want to use php, you'll need to edit the config file.

sudo vim /etc/nginx/sites-available/
-

The following code needs adding within the XXX block

+

The following code needs adding within the server block.

location ~ \.php$ {
 	include snippets/fastcgi-php.conf;
-	fastcgi_pass unix:/run/php/php-fpm.sock;
+	fastcgi_pass unix:/run/php/php<VERSION>-fpm.sock;
 }
-

This will use nginx's fastcgi-php.conf snippet which is more secure by deafult than many other php/nginx configs because it 404s if the files doesn't exist. Read Neal Poole'sDon't trust the tutorials for more info.

+

This will use nginx's fastcgi-php.conf snippet which is more secure by default than many other php/nginx configs because it 404s if the requested file doesn't exist. Read Neal Poole's Don't trust the tutorials for more info.

Reload NGINX

sudo systemctl reload nginx

Test it works

-

Create a PHP file e.g. filename.php in the website's directory, and add the snippet below into it

-
+

Create a PHP file e.g. filename.php in the website's directory, and add the snippet below into it.

+
<?php phpinfo(); ?>

Go to that webpage in your browser e.g. domain.co.uk/filename.php, and if php is working you should see a dump of your PHP's version, headers, etc.

Make nginx use index.php as homepage/root

-

Now we'll set nginx to load up index.php as the root of the website, if it exists. Open the site's config with an editor

+

Now we'll set nginx to load up index.php as the root of the website, if it exists. Open the site's config with an editor.

vim /etc/nginx/sites-available/
-

Change the index line to read as below. This will then tell the server to load index.php, and if it doesn't exists, load index.html in it's stead

+

Change the index line to read as below. This will then tell the server to load index.php, and if it doesn't exists, load index.html in its stead.

index index.php index.html
diff --git a/guides/adminer-setup.html b/guides/adminer-setup.html index 2916b7d..a749f4e 100644 --- a/guides/adminer-setup.html +++ b/guides/adminer-setup.html @@ -50,10 +50,10 @@ chmod 755 /var/www/html/adminer.php

Access it

-

Head to your /adminer.php, and you should load into the adminer login. Using your mysql/mariaDB credentials, you can then login, and use the GUI to manage your database(s)

+

Head to your <WEBSITE/IP>/adminer.php, and you should load into the adminer login. Using your mysql/mariaDB credentials, you can then login, and use the GUI to manage your database(s)

Make it a directory, not a file

-

Instead of accessing /adminer.php?, we can make it look like /adminer/

+

Instead of accessing /adminer.php?<ARGUMENTS>, we can make it look like /adminer/<ARGUMENTS>

location /adminer/ {
 	root /var/www/html ;
 	try_files $uri $uri/ /adminer/index.php/$is_args$args ;
@@ -62,16 +62,16 @@ chmod 755 /var/www/html/adminer.php

Password Protect

An additional level of security, just in case. Using Htaccess, any file, or directory can be password protected

sudo apt install apache2-utils
-htpasswd -c /home//.htpasswd admin
+htpasswd -c /home/<USER>/.htpasswd admin

Add to location

Add the location of the auth file to the adminer location block

auth_basic "Adminer" ;
-auth_basic_user_file /home//.htpasswd ;
+auth_basic_user_file /home/<USER/>.htpasswd ;

They block should look like below

location /adminer/ {
 	auth_basic "Adminer" ;
-	auth_basic_user_file /home//.htpasswd ;
+	auth_basic_user_file /home/<USER>/.htpasswd ;
 	root /var/www/html ;
 	try_files $uri $uri/ /adminer/index.php/$is_args$args ;
 }
diff --git a/guides/backup-with-rsync.html b/guides/backup-with-rsync.html index 241eac5..0a7d210 100644 --- a/guides/backup-with-rsync.html +++ b/guides/backup-with-rsync.html @@ -59,8 +59,7 @@
rsync -auv $USER@$HOST:$BACKUP $RESTORE

Notes/Advanced

-

--r recursive. All files/directories in the path will be backed up
+
-r recursive. All files/directories in the path will be backed up
 -a archive mode. Recursive, but with file permissions, symlinks, etc retained.
 -z compress
 -b backups
diff --git a/guides/get-a-domain-name.html b/guides/get-a-domain-name.html
index 89e653c..830c62b 100644
--- a/guides/get-a-domain-name.html
+++ b/guides/get-a-domain-name.html
@@ -4,7 +4,6 @@
 		
 		
 		
-		
 		
 		
 		
@@ -33,19 +32,19 @@
 
 		
-

A domain name, as many will know is what people typing into their browser, e.g. google.com, facebook.com, etc.

-

The primary use for these is to have a memorable thing for users, instead of needing to type the IP address of the server

+

A domain name, as many will know is what you type into a browser to access a website. Without a domain name, everyone accessing your server/website would need to be entering the IP address.

Choose a registrar

-

First thing is to choose a registrar (who you are leasing the domain from). You can search for "domain name registrars" and find who is cheapest. So long as they handle DNS (which all I've used do) you're good.

+

First thing is to choose a registrar (who you are leasing the domain from). You can search for "domain name registrars" and find who is cheapest. So long as they handle DNS (which most do) you're good.

I'm currently using tsohost.com, as they're pretty cheap, and besides a few little issues, it works for me.

Choose a domain name

-

On the registrar's website there will be a section to purchase a domain. Upon clicking this you'll likely be greeted with a searchbar, search for whatever domain you'd like here, and they'll let you know if it's available, and what similar domains there are

+

On the registrar's website there will be a section to purchase a domain. Upon clicking this you'll likely be greeted with a searchbar, search for whatever domain you'd like here, and they'll let you know if it's available, and what similar domains there are.

Select the domain(s) you wish, and add it/them to your cart.

Purchase your domain name

-

Simply checkout, and make your way through the process

+

Simply checkout, and make your way through the process. Tada, you now have a domain name!

+

Next up you'll need to link your server and domain name with DNS.

diff --git a/guides/guide-to-server-hosting.html b/guides/guide-to-server-hosting.html index 4e6d7fc..447293a 100644 --- a/guides/guide-to-server-hosting.html +++ b/guides/guide-to-server-hosting.html @@ -34,28 +34,36 @@

If you want to start getting into server hosting, system administration, or just want to get a basic minecraft/web server up for you and your friends, then welcome. We all start somewhere, and I would love if I could get your foot in the door.

-

Notice

-

This is heavily a WIP, so I'll be adding to this guide whenever I get time, and will update it's readibility, and correct/add anything missing once it's 'complete'. If I didn't put it up in an unfinished state, it would never go live, so bear with.

Basic Server setup

Now you officially own, and have setup a server. Currently all you can do is SSH into it though, so let's get some services on there

+

Virtualisation

+

Virtual machines allow you to use your server as multiple servers at once, with different operating systems, services, files, etc. If you're self-hosting this is a great way to separate concerns, having one system for each distinct task.

+ +

Nginx Webserver

A great first service for any server is a website, even if it's just a little page to let people know you own the server/domain name

MariaDB Database

@@ -63,63 +71,33 @@

Backup your server!

Backups are super useful. If something breaks, or gets accidentally deleted you can always use a backup to get it back

- - - -

Run virtual machines

-

Virtual machines allow you to use your server as multiple servers at once, with different operating systems, services, files, etc. If you're self-hosting this is a great way to separate concerns, having one system for each distinct task.

-

Additional services/potential guides

Unless there is an anchor, these are all "TODO", and may just be omitted from this list

Useful tidbits

Additional Services

  • git
  • -
  • samba
  • -
  • Open Media Vault
  • -
  • umami
  • -
  • uptime kuma
  • +
  • Uptime Kuma
  • torrentbox
  • -
  • jellyfin
  • +
  • Jellyfin
  • VPN
  • -
  • mailserver
  • -
  • Host client websites
  • -
- -

Game Servers

-
    -
  • minecraft
  • -
  • terraria
  • -
  • factorio
  • -
- -

Additional guides

-

These are some guides for specific use-cases, that will aid with setting up -

    -
  • Basic Homeserver for a web developer/designer
diff --git a/guides/initial-server-setup.html b/guides/initial-server-setup.html index be31c41..e60f8f1 100644 --- a/guides/initial-server-setup.html +++ b/guides/initial-server-setup.html @@ -33,13 +33,19 @@
-

This section assumes you have a fresh Debian 11 install on a server (either physical or VPS)

-

It will cover installing the essentials for access, and basic security so you don't need to worry in the future. This section may seem a little daunting for a first-time linux user, but most of it is copy/paste, hopefully with enough description to understand what is being done. Just remember not to copy the $/root$ they're there to show what user/directory we're in.

+

This section assumes you have a fresh Debian install on a server (either physical or VPS)

+

It will cover installing the essentials for access, and basic security so you don't need to worry in the future. This section may seem a little daunting for a first-time linux user, but most of it is copy/paste, hopefully with enough description to understand what is being done.

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.

+

Login

+

Perhaps silly, but login as your user with root priveleges or the root user if a user isn't currently setup.

+

For the first few steps it's written as if you're logged in as root, if you followed my install guide, this won't have a password, so we'll change user with the following command

+
sudo su -
+

Now just follow along with the remainder of the guide. If you wish not to change users you could also just add sudo in-front of the commands to run them as root that way.

+

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.

@@ -48,13 +54,14 @@

Install essential packages

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

-
apt install sudo ssh
+
apt install sudo ssh -y

Some useful packages too

-
apt install vim htop wget curl tmux
+
apt install vim htop wget curl tmux -y

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

+

This can be ignored if my guide was followed, or you already have a user setup. Some VPS just have root however, so I believe this should be included.

+

The reason for a new account instead of using root, basically comes down to security. If you want multiple people on the server too, it's best to have a unique account for each.

adduser $USERNAME$	
 usermod -aG sudo $USERNAME$
@@ -62,20 +69,19 @@ usermod -aG sudo $USERNAME$

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

(Local server) Set static IP

-

If the server is a physical PC in your home you will need to set a static IP, otherwise your router could assign a differnent IP on reboot, and this would mess with port forwarding, and internal DNS.

-

Set static IP for local server

-

Port forwarding for local server

-

If you've set the static IP for your local server, you'll also have an additional step when making public (internet served) services, as unlike a VPS your ISP will likely have all outbound ports disabled by default

-

Port forward your local server

+

If the server is a physical PC in your home you will need to set a static IP, otherwise your router could assign a different IP on reboot, and this would mess with port forwarding, and internal DNS.

+

If you're using a VPS, this step can be ignored.

+

Set static IP for local server

Secure ssh

-

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

+

Although this is optional, I recommend it, as SSH (secure shell) will likely be the primary means of access to the server. You don't want to be next to it whenever you've got a change to make.

+

Open the following file with your editor of choice, I use vim.

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

+

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

+

Below the Port line, add a new line and write Protocol 2 this enables ssh2, which is more secure than the standard ssh protocol.

(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
@@ -84,52 +90,73 @@ usermod -aG sudo $USERNAME$

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

+

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

apt install ufw
ufw default deny incoming &&
 ufw default allow outgoing &&
-ufw default allow 2020 &&
+ufw allow 2020 &&
 ufw enable

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

ufw allow $PORT
-

or

-
sudo ufw allow $PORT
-

Then enable it, making sure you've allowed ssh first

-
sudo ufw enable

Set hostname

-

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

+

Setting the name for a server is not an important step, but it's nice to have each server easily identifable.

+

Simply change the hostname within the two files below. Ensure they share the same name between files.

vim /etc/hosts

and

vim /etc/hostname
-

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

-
-

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
+
+

This next section is to be done via a terminal, or an SSH client e.g. PuTTY for Windows. This part of the guide is written for a Unix terminal.

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

+

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

ssh $USER$@$HOST$ -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.

+

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 recommend verifying this whenever asked.

+ +

Verify SSH

+

To verify, you'll need to run the following command on the server.

-
ssh-keygen -l -f /etc/ssh/ssh_host_$KEY$_key.pub
+
ssh-keygen -l -f /etc/ssh/ssh_host_ed25519_key.pub
+ +

Then if the key the server shows matches that on your PC's SSH prompt, type yes and hit enter from your PC.

+ +

SSH without a password

+

To be more secure, and to SSH faster we can setup an SSH key, and use that for user authentication.

+

Create an SSH key

+

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

+
ssh-keygen -t ed25519
-

Replace $KEY$ with the key the message is asking about (e.g. ecdsa, rsa, ed25519). Then if key the server shows matches that on your PC you are SSHing from, type yes and hit enter

+

Copy the SSH key onto the server

+

From the terminal there's a nifty command to copy ssh keys to a server.

+
ssh-copy-id -p 2020 -i ~/.ssh/id_ed25519 USER@HOST
-

TODO:(Optional) Fail2Ban

+

Alternatively you can add the key to the server manually. This is recommended, especially when adding other users.

+

First on your PC you need to run the following, and take note of the output.

+
cat ~/.ssh/id_ed25519.pub
+

Then on the server, open the following file, and add the output to a new line.

+
vim /home/USER/.ssh/authorized_keys
+ +

SSH again

+

Now simply run the same ssh command as before, and you shouldn't get a password prompt.

+
ssh $USER$@$HOST$ -p 2020
+ +

(Optional) Fail2Ban

+

Fail2ban is used to periodically check server logs, and bans IPs that appear to be trying to brute-force into your server. It's only "required" for servers exposed to the internet.

+
apt install fail2ban -y
+
systemctl enable fail2ban
+

There's a lot of options for fail2ban, this just installs it. For a little more detail checkout Crownclouds fail2ban guide.

TODO:(Optional) Unattended Upgrades

-

Updates to a server typically want to be done by a human in case things go wrong, but smaller updates can be set to be done automatically

+

Updates to a server typically want to be done by a human in case things go wrong, but smaller updates can be set to be done automatically.

+
apt install unattended-upgrades
+

The above downlads, and starts unattended-upgrades with some good defaults, but if you want a some more details check cyberciti'sunattended upgrades guide.

(Optional) Setup User preferences

These are a few things I personally like to have on a basic server. If you have your own preferences, dotfiles, or intend to use oh-my-zsh fell free to skip over this.

@@ -142,27 +169,12 @@ ufw enable
set -o vi

Aliases

-

Instead of typing out long commands you can alias them, and type a shorthand version.I've written an article about aliases that explains setting up, and aliases I use. Below are some essentials for those that don't want to jump to another article.

+

Instead of typing out long commands you can alias them, and type a shorthand version. I've written an article about aliases that explains setting up, and aliases I use. Below are some essentials for those that don't want to jump to another article.

alias ll="ls -lhtr"
 alias df="df -h"
 alias ta="tmux attach || tmux new"
 alias ipe="curl ifconfig.co"
-

Ctrl-L clear-screen

-

Sometimes a new system doesn't have this by default, and it's probably the thing I use most after ls.

-

Add, or create an .inputrc file

-
vim ~/.inputrc
-

Add the following line to the file

-
"C-l": clear-screen
- -

BashRC PS1

-

This will make your terminal look a little nicer, and display a directory path, user, and hostname. A ridiculously useful feature if you're managing multiple servers, or virtual machines

-

This is also in the .bashrc file, so open that up

-
vim ~/.bashrc
-

Then add the following to the bottom of the file

-
export PS1="\[\e[01;33m\]\u\[\e[0m\]\[\e[00;37m\]@\[\e[0m\]\[\e[01;36m\]\h\[\e[0m\]\[\e[00;37m\] \t \[\e[0m\]\[\e[01;35m\]\w\[\e[0m\]\[\e[01;37m\] \[\e[0m\]\n$ "
-

If you want to customise your terminal, you can do so with .bashrc PS1 generator. -

Reads shouldn't write!

Another personal opinion, and change is to enable noatime, and nodiratime. Be careful with this change! And ignore if you followed my Debian install guide, as they're already enabled.

Basically without these, when a file is opened (read) on your filesystem, a write is invoked to update the time it was opened, which causes unwanted writes, and CPU cycles.

diff --git a/guides/install-kvm-virtual-machine.html b/guides/install-kvm-virtual-machine.html index 3e2eac0..2659cd4 100644 --- a/guides/install-kvm-virtual-machine.html +++ b/guides/install-kvm-virtual-machine.html @@ -40,6 +40,20 @@

Install with virt (CLI)

Install with virt-manager (GUI)

+ +By default virsh lists vms belonging to user +virsh --connect qemu:///system list --all +The above run as root shows all vms + + +For virtmanager, etc to controll vms from an remote host +It needs ssh-key shared + +If a different port, then use virt-manager -c 'qemu+ssh://myuser@192.168.1.139:2222/system?keyfile=id_rsa' + +e.g. +virt-manager -c 'qemu+ssh://nathan@aney.co.uk:2020/system?keyfile=id_rsa' +
diff --git a/guides/install-mysql-mariadb.html b/guides/install-mysql-mariadb.html index c5e64d4..67cdae9 100644 --- a/guides/install-mysql-mariadb.html +++ b/guides/install-mysql-mariadb.html @@ -40,15 +40,20 @@

Secure Install/Setup

sudo mysql_secure_installation
+

Run the above command, and follow the instructions, if you don't want to then follow mine.

+

Press enter for the current password, and again when asked if you want to set a root password. Enter the password, then press enter for everything else.

Create Admin user

sudo mysql
-
GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
+
GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY '<DESIRED_PASSWORD>' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;

Test it works

+

Simply try logging in as the admin account.

+
mysql -u admin -p
+

It should ask for a password, so enter your DESIRED_PASSWORD, and if you get mysql access, it's successful.

(Optional) Make it easier to access on command line

If you're working with a terminal, when calling mysql you'll need to enter a password each time. You can store the passwordwith a special .cnf file, making it faster to get into writing SQL.

@@ -56,9 +61,9 @@
vim ~/.my.cnf

Add the following, with your credentials

[mysql]
-user=
-password=
-

The above can be used for mysqldump, mysqladmin, and others too, by replacing the [mysql] block

+user=<USERNAME> +password=<PASSWORD> +

The above can be used for mysqldump, mysqladmin, and others too, by replacing the [mysql] block, with the related. e.g. [mysqldump].

diff --git a/guides/kvm-optimisation.html b/guides/kvm-optimisation.html new file mode 100644 index 0000000..4ffdb84 --- /dev/null +++ b/guides/kvm-optimisation.html @@ -0,0 +1,73 @@ + + + + + + + + + + + + KVM Optimisation + + + +
+ Jump directly to main content +

KVM Optimisation

+ + +
+ +
+
+ +
+
+

KVM Optimisations

+ +transmit queue +virsh domiflist +# this is then the txqueuelen change below ??? +# changing to 4096 +ifconfig txqueuelen + +txqueuelen (iwbcman comment) +defaults to 1000, apparently 200 is good + +ip link set eth0 txqueuelen 200 +vim /etc/network/interfaces +add +post-up /sbin/ip link set eth0 txqueuelen 200 +to the end + +If virtual hdd is slow can try +Cache mode: none (not default!) +I/O mode: native +https://unix.stackexchange.com/a/48584 + +non caching on dirves? +https://blog.jdpfu.com/2012/07/30/improving-kvm-performance +://documentation.suse.com/smart/linux/html/concept-virtual-disk-cache-modes/concept-virtual-disk-cache-modes.html#:~:text=A%20disk%20cache%20is%20a,example%2C%20by%20setting%20its%20type. +On VM turning cache off essentially acts like accessing the drive itself. No exactly a passthrough, but decent enough + +http://www.linux-kvm.org/page/Tuning_KVM + +
+
+ + + + + diff --git a/guides/server-install-debian.html b/guides/server-install-debian.html index 75c8f15..da7f9c8 100644 --- a/guides/server-install-debian.html +++ b/guides/server-install-debian.html @@ -43,8 +43,8 @@

Download and Burn the ISO

First thing is to get the install media setup. If you know how to burn an ISO, go ahead and get that done, I'll wait for you in the next section. If not follow below.

-

Download the latest debian ISO from the debian website, at the time of writing it's this release, but get it from their page.

-

Download Balena Etcher for your device (Windows, MacOS, Linux), and install it

+

Download the latest debian ISO from the debian distrubution page, at the time of writing it's this release (assuming you're installing on a 64bit PC), but get it from their page.

+

Download Balena Etcher for your device (Windows, MacOS, Linux), and install it

Then open Etcher (with an empty USB plugged in), select the USB, and the downloaded ISO image, then hit run.

When finished remove the USB and plug it into the PC you want to install Debian to

@@ -56,53 +56,73 @@

Like above, press the key to get into either a one-time boot menu, or the bios. From there select your USB as a boot override. This will boot from the USB just this time, and then revert to the normal boot order.

Start install

-

When you're greeted by a debian boot page, select "Install" (that's what I'll be using) but "Graphical Install" is also fine, as it's essentially the samething, but you can use a mouse.

+

When you're greeted by a debian boot page, select "Install" (that's what I'll be using) but "Graphical Install" is also fine, as it's essentially the same thing, but you can use a mouse.

Localisation

As if you are filling out an online form, simply ensure the boxes are correct to your language, location (sets time, and download servers), and keyboard layout.

-

Network, and server name

-

If you're using DHCP, this can be...

- TODO

Hostname

-

What you wish to call your server, I like to give names that are quirky, but still kinda explain what they do. For example, my webserver is "spiderverse", and my NAS is "lilnas", etc.

+

What you wish to call your server, I like to give names that are quirky, but still kinda explain what they do. For example, some names I've used are "spiderverse" for a web server, and "lilnas" for a NAS, etc.

Domain name

-

Leave this as default, and hit continue.

+

Leave this as default "home", and hit continue.

-

Create User

+

Set up users and password

+

The first thing you'll see is a screen asking for a root password.

Don't set a root password

-

This will ask for a root password. Do not enter a password, and simply git the Enter key, then again when it asks for the password the second time. A root user with a password is a vulnerability, so we're avoiding this.

+

Simply hit the Enter key, then again when it asks for the password the second time. A root user with a password is a vulnerability, so we're avoiding this.

Create your user (admin account)

-

Now enter your username, and password as the installer requests. This account will be added to the sudo group, making it an admin with access to root, and root commands.

+

Now enter your username, and password as the installer requests.

+

This account will be added to the sudo group, making it an admin with that can act as the root user.

Disk Partitioning

For this I am assume you're using a new drive, or at least one that you don't want any of the data on it

-

Auto-partitioning

-

You can do this, and it's recommended if you're new to linux. Once you've got the hang of it, you can always re-install your server from scratch (I recommend this a couple of times).

-

Also select to have all files in one partition, as it's the simplest option.

-

Finish Partitioning, and done.

+

Guided/Auto-partitioning

+

You can do this, and it's recommended if you're new to linux. Once you've got the hang of it, you can always re-install your server from scratch (I recommend this a couple of times if it's non-integral).

+

Select Guided - use entire disk then select the drive you want to boot from.

+

Then select All files in one partition (recommended for new users), as it's the simplest option.

-

Manual Partitioning

-

For a little more control over the partitioning, this is the option. If you are a beginner I'd just go with auto for now, but follow this if you desire.

- TODO +

Manual Partitioning

+

I've opted to leave this out, as it's a beginner guide. If you're reading this though I typically don't create a swap partition, but the guided installer does. It's no problem, but following this guide makes it redundant.

-

Preferences

-

Skip Swap (for now)

+

(Optional) Preferences

+

With your disk partitioned select the partion that has a / at the far right, and hit Enter.

+

Go to Mount Options, and select (using Space) noatime, and nodiratime. Then hit Enter, and select Done setting up the partition.

-

Scan Additional Media

-

Unless you've addition drivers, etc. (You probably don't) hit No

+

Finalising Partitioning

+

Simply hit Enter on Finish partitioning and write changes to disk at the bottom of the page.

+

Another screen will appear to verify you wish to partition, hit Yes, and it'll begin partitioning. Give it a little time.

-

Configure Mirror

+

Configure the package manager

+

A simple one, select your country, hit enter to the top selection, hit enter again when it asks for a proxy (unless you know what you're doing), and sorted.

Popularity Contest

+

I typically select No here, but read what it is and select for yourself.

Software Selection

- -

Install Grub Boot Loader

+

Now tasksel will load up, and ask if you want any software installed during setup.

+

I choose to deselect everything pre-selected (the ones with asterisks), however for a new setup keeping standard system utilities is a-ok.

+

If you're after a GUI experience you can select Xfce as it's pretty lightweight, however I'd recommend going with no GUI for a server.

+

Once you've selected what to install, hit Enter.

Reboot, and enjoy!

+

Reboot your server, and tada!

Setup Swap

+

I mentioned earlier I don't setup a swap partition, and that it'd be redundant if you follow this guide, so here we go.

+

Swap sizes vary per PC as different services use more RAM, etc. A decent(ish) rule of thumb is to set half your RAM size as the swap size, but to be honest 8GB will likely suffice.

+

Create the swap file

+
sudo fallocate -l 8G /swapfile
+

Set permissions

+
sudo chmod 600 /swapfile
+

Set the file as a swap area

+
sudo mkswap /swapfile && sudo swapon /swapfile
+

Set on boot

+

Open /etc/fstab with a text editor. I'll use vi for this.

+
sudo vi /etc/fstab
+

Press gg, followed by Shift+o, then type the following.

+
/swapfile swap swap defaults 0 0
+

Then press esc, followed by shift+ZZ.

+

Next steps

Now that you've got a basic Debian install, you'll need to configure, and install a few things. I've written a little something, somthing like that, so check how to setup a new server install

diff --git a/guides/setup-git-server.html b/guides/setup-git-server.html index 524bcea..b0c0bf6 100644 --- a/guides/setup-git-server.html +++ b/guides/setup-git-server.html @@ -57,7 +57,7 @@

Use the git server

With all the setup out the way, the git server is now usable as a remote for any of your git repos.

-

So on another PC...

+

So on another PC, you can use git as normal. For example.

Add remote to existing repo

git remote add origin git@<your-server>:/<repo.git>

Clone the repo

@@ -69,7 +69,7 @@

Giving you something like this

git clone git@<your-server>:<port>/<repo.git>
-
+

Completed

From here you can use git as you would via any other provider, but with the knowledge that your remote is yours.

diff --git a/guides/setup-kvm-bridge.html b/guides/setup-kvm-bridge.html index 186e5cc..0a2d91d 100644 --- a/guides/setup-kvm-bridge.html +++ b/guides/setup-kvm-bridge.html @@ -33,69 +33,68 @@
-

A bridge network is a means to connect/bridge different networks together to act like a single network. In this case, it allows any connections to the bridge network to get their own internal IPs, as if plugged into the network directly, and work as you'd expect a completely new physical PC to work. i.e. Accessble to other clients outside of the host.

+

A bridge network is a means to connect/bridge different networks together to act as a single network. In this case, it allows any virtual connections to the bridge network to get their own internal IPs, as if plugged into the network directly.

+

Install bridge-utils

sudo apt install bridge-utils
-

Find the network to bridge

-

First we need to find the network we want to bridge to the VMs

-
ip a
+

Find the network device to bridge

+

First we need to find the network device we want to bridge to the VMs.

+
ip link
+

You'll likely have a device called something similar to enp1s0, or eth0.

-

Bridge it

+

Create the bridge network

This will be familiar to those who have set a static ip on linux, as it's essentially the same, with a few additional lines related to bridging

-

This can be done by editing /etc/network/interfaces

+

Remove interface from interfaces file

+

First step is to remove any references to your network device from /etc/network/interfaces, if this file is untouched there will likely be two lines at the bottom.

sudo vim /etc/network/interfaces
-

And setting the following lines

- -

Change existing port to manual

-

There will already exist some lines with your chosen network adapter, such as

-
iface enp2s0 inet auto
-

Change this to contain manual instead

-
iface enp2s0 inet manual
-

Static Bridge

-

If you want your server to have a static IP use this

+

Create a new bridge interface

+

Now create a file in the /etc/network/interfaces.d/ directory, with the name of your bridge (I like br0).

+

Static IP

auto br0
-iface br0 inet static
-	bridge_ports enp2s0 # which port(s) to bridge together
-                address 192.168.0.100 # Static IP
-                netmask 255.255.255.0
-                network 192.168.0.1
-                broadcast 192.168.0.255
-                gateway 192.168.0.1
-                bridge_stp off # New
-                bridge_fd 0 # New
-                bridge_maxwait 0 # New
-                dns-nameservers 8.8.8.8 8.8.1.1
-

Dynamic Bridge

-

If instead you wish your server to have a dynamic IP (not recommended). A bridged network can be set, with a dynamic DHCP set IP

+iface br0 inet static # Name the same as your file (br0) + address 192.168.0.100 + broadcast 192.168.0.255 + netmask 255.255.255.0 + gateway 192.168.0.1 # Normally your router's IP + dns-nameservers 192.168.0.1 8.8.8.8 8.8.4.4 # Don't set if resolveconf is installed, comment if internet borked + bridge_ports enp1s0 # Your device name + bridge_stp off # Disable Spanning Tree Protocol + bridge_waitport 0 # No delay before a port becomes available + bridge_fd 0 # No forwarding delay (Connects to network immediately) +

Dynamic IP

iface br0 inet dhcp
     bridge_ports enp2s0
-

Create Virtual Network

-

To make it easier to manage with VMs, this new bridge can be made into a Virtual Network.

-

Open up a text-editor, and create a file called bridged-network.xml

-
vim bridged-network.xml
+

(Optional) Create Virtual Network

+

To make it easier to manage with VMs, this new bridge can also be made into a Virtual Network (Basically so you can select it from a dropdown).

+

Create XML file

+

Open up a text-editor, and create a file called br0.xml, named after the bridge itself.

+
vim br0.xml

Enter the following, then save

<network>
-	<name>bridged-network</name>
+	<name>br0</name>
 	<forward mode="bridge"/>
 	<bridge name="br0"/>
 </network>
-

Then pass the file to virsh net-define

-
sudo virsh net-define bridged-network.xml
-

Active, and auto-start the new network

-
sudo virsh net-start bridged-network
-
sudo virsh net-autostart bridged-network
+ +

Create the virtual network

+
sudo virsh net-define br0.xml
+

Activate, and auto-start (on boot) the new network.

+
sudo virsh net-start br0
+
sudo virsh net-autostart br0
+

You can now remove the br0.xml file.

Reload the network

sudo systemctl restart networking
-

If this creates the bridge, but claims to have failed, restart your PC

+

This may claim to have failed, but if checking with ip link shows the bridge, reboot. Essentially the bridge has been brought up, and it's trying to bring it up again (and can't), then throws an error.

sudo reboot

Check it's there

-

Run another check for networks, and you should now see br0

-
ip a
+				

Run some checks and you should now see br0, with an IP4 address.

+
ip a
+
ping google.co.uk
diff --git a/guides/setup-qemu-kvm.html b/guides/setup-qemu-kvm.html index 32df243..1aa97fb 100644 --- a/guides/setup-qemu-kvm.html +++ b/guides/setup-qemu-kvm.html @@ -10,13 +10,13 @@ - Setup KVM/QEMU virtualisation + Setup QEMU/KVM virtualisation
Jump directly to main content -

Setup KVM/QEMU virtualisation

+

Setup QEMU/KVM virtualisation


@@ -33,8 +33,54 @@
-

This is an intro, you gotta believe me

-

Heading

+

Virtualisation is the act of creating a virtualised computer (guest), inside another computer (the host) by sharing the hardware. This allows a single host the ability to run all your services, whilst keeping a level of SoC.

+ +

Enable in the BIOS

+

To run virtual machines, certain flags in the bios need to be set. If you don't want to bring down an existing server to check, then check the next section first.

+
    +
  • Reboot your PC
  • +
  • At the BIOS splashscreen, press your motherboard's prefered key (typically ESC, F3, or F12).
  • +
  • Find and enable the virtualisation setting(s). +
      +
    • One of VT-x, AMD-V, SVM, or Vanderpool.
    • +
    • One of Intel VT-d, or AMD IOMMU (if available)
    • +
    +
  • +
+ +

Check Virtualisation is enabled

+

Double check to make sure your server can be used for virtualisation, if you've enabled it in the BIOS it should be good. Just run one of the following command

+
lscpu | grep 'Virtualization'
+
grep -E --color '(vmx|svm)' /proc/cpuinfo
+ +

Install the packages

+

The easiest part, just copy and paste the below to install the required packages.

+
sudo apt install qemu-kvm libvirt-clients libvirt-daemon libvirt-daemon-system virtinst
+ +

Sessions

+

There are two different session types for VMs, user, and system sessions. If you are using a desktop, and intend to virtualise other desktop OSs I recommend user sessions. If you're setting up a server hypervisor, then use System sessions.

+ +

User Session

+

A user session VM is what I recommend for personal PCs, laptops, etc. as it's the best option for desktop virtualisation (e.g. a Kali install for l33t hackers).

+ +

Add user to group

+
sudo adduser $USER libvirt
+ +

Enable default network

+

Check the name of your default network (typically just 'default').

+
sudo virsh net-list --all
+

Enable the network.

+
sudo virsh net-start default
+

(Optionally) Set it to turn on with system boot.

+
sudo virsh net-autostart default
+ +

System Session

+

For now all that's needed to know is that you run sudo before any virsh commands, and that the VMs will launch with root permissions.

+ +

Extra

+

Setup bridge adapter for KVM

+

Optimisations for KVM Virtual Machines

+
diff --git a/guides/virsh-cheatsheet.html b/guides/virsh-cheatsheet.html index 89a7e65..7a2a366 100644 --- a/guides/virsh-cheatsheet.html +++ b/guides/virsh-cheatsheet.html @@ -77,6 +77,11 @@
virsh snapshot-delete --domain $vm --snapshotname $snapshot_name

(TODO)Drive management

+

Resize virtual drives

+

Find the name of your drive.

+
virsh domblklist $vm
+

Resize with qemu

+
sudo qemu-img resize /location/drive.qcow2 +10G

Change Memory

In variantions of 512M, 1G, etc

diff --git a/guides/vm-seperation-of-concerns.html b/guides/vm-seperation-of-concerns.html index f9ddef1..e210c46 100644 --- a/guides/vm-seperation-of-concerns.html +++ b/guides/vm-seperation-of-concerns.html @@ -79,7 +79,6 @@

Why not use a dedicated server for each concern?

You can! No-one's going to stop you, but unless each concern requires (i.e. needs the dedicated hardware/isolation) its own dedicated server, it's hugely redundant. Again NAS as an example, would be good for a dedicated machine, as it'll be safer if there's no additional chance it goes down due to failure of an unrelated service.

-

Virtual Machines are wonderful, as they allow you to make use of more powerful/high spec machines while minimising the wasted usage...

diff --git a/projects.html b/projects.html index 9a7d58d..914fb25 100644 --- a/projects.html +++ b/projects.html @@ -33,7 +33,6 @@

Current Projects

-

Here to hold me accountable, as I cannot finish my own projects

Personal Website