Adam's Digital Garden

Hosting Server @ Home

Why a Home Server?

The first question is why do you want a computer separate from the computer you are using, and then choose where this 2nd machine should run. It can be at home, you can rent a remote server, or you can subscribe to a service, such as Dropbox or iCloud.

The advantages of a home solution are:

  1. Your data is kept in your own country, meaning that it is your country’s privacy laws that control data access.
  2. It can be cheaper, especially if you already have a computer lying around
  3. There are more options of what you can do, A home server does not only store my backup files, but can also host a website, run a plexserver, and act as an entry point to my home network. You will need to setup the security correctly
  4. You can take your files with you for remote access. I can disconnect the external hard drives and access all my files directly should the need arise. Also access across the home network is much faster than pulling files from a remote server.


  1. Requires more setup, especially if you are only after remote file access. Solutions such as oneDrive, Dropbox, pCloud amoung others will be easier to setup and more reliable
  2. Your files are at home, meaning they can physically stolen or destroyed
  3. If something goes wrong you have no one else to blame but yourself

My home server first used CentOS 8 but now I using Debian. Some of the sections of the guide have been not been updated so be sure to double check if the commands run on your server.

Home Network with Debian

This guide is for setup and administration of a home server to be used for backup, Samba file sharing and to host a non-critical websites. Non-critical in the sense that if it is down for a week no one will be affected.

I am using an Inspirion 1545 from 2009. The advantages of an old laptop are:

CentOS Setup

Confirm the version of CentOS you have installed with:

$ hostnamectl
   Static hostname: inspire
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: cd274e46c17e49d3900e131a379b6f5a
           Boot ID: 61a6679d2ced4ab28916179d679e3097
  Operating System: CentOS Stream 8
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-193.28.1.el8_2.x86_64
      Architecture: x86-64

The version of linux determines which command can be used to check the version. Some alternatives are:

$ cat /etc/os-release
$ lsb_release -a
$ hostnamectl

Install Ethernet Driver

To install the ethernet driver identify the hardware device you have and the find the correct driver using the device ID and name.

No ethernet device detected

$ nmcli device status

See all PCI devices

$ lspci

Search online for the correct driver and match the version with the installed version of CentOS, in my case 8.2…

install the driver with rpm -i kmod*

reboot, and it works.

You will now need to add the repository so CentOS knows to look for updates.

sudo rpm --import

sudo yum install


Set Hostname

hostnamectl set-hostname NAME

Mac Address retrieval

ifconfig -a #CentOS

and look for ether value under your ethernet device name.

Speed checks

sudo dnf install iperf3

iperf3 can also be installed for windows. To use iperf3 run it in server mode on one device and client mode on the 2nd.

# server mode
iperf3 -s
# client mode
$ iperf3 -c $IP_ADDRESS

iperf can be used to check how your wireless speed changes in your home. I found that there is a 20Mbps drop between the office and the living room.

SSH log

journalctl -u sshd

Mount External drive

Get the location

$ lsblk

Mount external hard drive

$ mkdir /mnt/extdrive
$ mount /dev/sda1 /mnt/extdrive

Check file format of all drives

$ df -Th 

Mount drives on boot using UUID

$ sudo blkid
$ vim /etc/fstab

And add the drives along with the mount point and diskformat to the bottom of the file. Now on reboot the external drives will be mounted.

UUID=20f70136-acf2-11ec-b909-0242ac120002 /mnt/drive1       btrfs
UUID=28c5d5cc-acf2-11ec-b909-0242ac120002 /mnt/drive2       ext4
UUID=2cb1fbe8-acf2-11ec-b909-0242ac120002 /mnt/drive3     ext4

Mac Partition

To read a mac partitioned external hard drive:

yum install kmod-hfsplus
yum install hfsplus-tools

Format partition to ext4

First you need to unmount the drive if you have been using it. For example:

umount /dev/sda2

Choose which device you want to format. In the case of sda1, use:

mkfs.ext4 /dev/sda1

Shell Configurations

Identify Shell

echo $SHELL

ln -s file1 link1

Symlinks are shortcuts in Linux speak.


With an alias you can assign a name to any custom command.


To make the alias permanent you first need to know which type of shell you are using, “Identify shell” and edit the matching profile.

If using bash, the file to edit is ~/.bashrc

If using zsh, the file is ~/.zprofile

Once the alias is added you need to log out or source ~/.bashrc

Samba to Share Files on Home Network

Samba shares a chosen directory from your server with your home network. I use it to share movies with Apple TV and to run backups over the network.

#install samba

sudo yum install samba samba-client

# start samba and nmbd. nmd part of samba to connect to Windows machines. 
sudo systemctl start smb.service

# start samba on startup
sudo systemctl enable smb.service

# allow through firewall
sudo firewall-cmd --permanent --zone=public --add-service=samba
sudo firewall-cmd --zone=public --add-service=samba

# create a samba account with access for existing user
sudo smbpasswd -a adam
# enable the user
sudo smbpasswd -e adam

Update the config file /etc/samba/smb.conf to:

        workgroup = SAMBA
        security = user
        passdb backend = tdbsam

        path = /mnt/drive1/Shared
        public = yes
        guest ok = yes
        guest only = yes
        guest account = nobody
        browsable = yes
        path = /mnt/
        browseable = no
        read only = no
        force create mode = 0660
        force directory mode = 2770
        force user = adam
        valid users = adam

and restart the samba service sudo systemctl restart smb

This config shares the /mnt/ directory to a user named adam. To connect to this drive from MacOS open Finder and press CMD-K and the login in smb:// It requires a password to connect.

The config also shares /mnt/wdpassport/Shared with all users on the network. To connect from Windows, select Add Network location from This PC context menu and add //

At first, I couldn’t see one of the directories. Check if SELinux is the cause by turning it off.

$ sudo setenforce 0

Then turn it back on and adgd a tag to share the directory.

$ $ sudo chcon -Rt samba_share_t $SHARED_DIRECTORY

Which took 25 minutes to run, so maybe there was a better way.

Modified from sources among which was linuxize.

To check machines currently connected to the Samba server you can use:

sudo smbstatus -S 

Sometimes the samba server stops working, and the quickest fix is to restart the server. This is quite a pain as the internal drive is encrypted and requires physical access to the machine. I need to find another way to share files.

Restarting the samba service is not enough. I couldn’t find anything useful in the log, only that it was awaiting connection.

VPN Setup

So the machine connects via a VPN service instead of directly.

As a Client

sudo dnf install openvpn

First check if connecting works as you expect: I used expressVPN and downloaded the my_expressvpn_denmark_udp.ovpn from the members area

sudo openvpn --config expressVPNconfig/my_expressvpn_denmark_udp.ovpn

You will then be asked for your username and password available from the same address as the ovpn file.

To check your ip has been changed you check your public IP with website like wget –O –q

To check your torrent traffic is being routed through the VPN you can use ipMagnet.

DNS settings

Your DNS settings controls what websites are available to your machine by restricting which urls are converted to IP addresses. There are DNS that can block adult websites and advertising addresses, meaning your company cannot access these, instead of blocking these sites.

To change your DNS you first need to stop Network Manger from changing the DNS. To edit Network manager /etc/NetworkManager/NetworkManager.conf add dns=none under [main]. Then you can add your own nameserver line in /etc/resolv.conf.


$ dnf install emacs

Connect Directly to Tmux Session

Scripts for connecting to tmux session

ssh -t $SERVERNAME "tmux attach-session -t adam || tmux new-session -s adam"

Kill all tmux sessions

tmux kill-server

Kill process

kill -9 ID

Disable Screen

If you know how to disable the screen without installing GUI let me know, otherwise after trying vbetool, xset, randr, disabling the backlight, and disabling the video driver I ended up installing GUI and having the power saver disable the screen.

Tried dnf group install "Legacy X Window System Compatibility" to get xrandr to see the display but no luck.

Finally what worked was installing CentOS with a GUI, and setting it as default, systemctl set-default The power saver then turns off the display.

To start the GUI from console use $ startx

Sleep and Wake

To sleep, $ sudo systemctl suspend

To wake the server I need the MAC address available from

$ ip addr show

To enable wakeonlan ethtool needs to enable it on the connection. Get the device name with nmcli

Check if wake on lan is enabled on the Wake-on setting in

$ sudo ethtool $DEVICE_NAME
# Enable Wake-on by using g
$ sudo ethtool -s $DEVICE_NAME wol g

The change in ethtools does not persist reboot. I shared a working solution on the CentOS forum

To send a wakeonlan signal from MacOS you need to install wakeonlan. I use (brew)[].

$ wakeonlan $MAC_ADDRESS 

Remote Suspend

Sleeping the PC remotely required root access to the machine and running systemctl suspend . I added my laptops public key to the servers root ssh access. External networks do not have direct access to the server. All connections are done via my raspberry pi introducing proxy jumps, as an alternative to key forwarding.


Host raspberryPI
    HostName $PUBLIC_IP
    User $USER
    port $OTHER_THAN_22

Host root-server
    HostName $LOCAL_IP
    User root
    port 22
    ProxyJump raspberryPI

Uploading with sftp

To upload to a remote server use sftp connect with:

sftp user@server-address 

Then use the put command with the following form

put -r src/path/to/local/dir dest/path/to/server/dir/

Useful installs and Commands

Adding libraries

$ sudo yum install wget #Download files from URL
$ sudo yum install epel-release #Extra Packages for Enterprise Linux.

When installing a package from source run checkinstall so that it can be removed with the package installer. However in a packaged Linux version, doing this can lead to problems down the line says CentOS forum admin.

Group Installs

yum group list install many packages at once, for example yum group install server with gui

Useful packages



Learnings Along the Way is library that allows applications to access the PCI subsystem. Source

Hibernating with $ systemctl hibernate requires decrypting the disks when starting up

Change Password passwd

Check inhibitors

systemd-inhibit --list

Plex Server

Plex Server uses TheTVDB for metadata to its files.

Clear CLI Screen

$ setterm -clear all > /dev/tty1

Centos Wiki Centos Forum


Automator Service JXA script to wake server from Touch Bar via an always on raspberry pi:

var app = Application.currentApplication();
app.includeStandardAdditions = true;
app.doShellScript('ssh raspberryPI "wakeonlan $MAC_ADDRESS" &');

Automator Service JXA script to suspend server from Touch Bar via an always on raspberry pi:

var app = Application.currentApplication();
app.includeStandardAdditions = true;

app.doShellScript('ssh root-server "systemctl suspend" &');