Skip to content

Setup

Installation

  • Download the latest ISO image of Ubuntu Server OS from this link.
    • It's recommended to use Alternate Mirror (Singapore/India) for faster downloads.
  • Use Balena (Etcher) on MacOS to burn the downloaded ISO image on to a USB drive.
  • Connect the USB to the server machine and restart it to install the OS.
    • You may have to change the boot order.
  • The installation process is pretty straight forward, but if you need assistance, this official guide will help.
  • Here are the details to be filled during installation:
    • Language: English
    • Keyboard Layout: English (US)
    • Base for installation: Ubuntu Server (Don't use minimized)
    • Storage configuration: Choose Custom Storage Layout (See details below on how to configure this)
    • Name: Pirate Developer
    • Server Name: pirateserver
    • Username: piratedev
    • Password: See iCloud KeyChain
    • Ubuntu Pro: Skip
    • Check Install OpenSSH server
      • Import SSH identity from GitHub (Username: PirateDevCom)
    • Custom Installations
      • microk8s
      • docker
      • etcd
      • aws-cli
  • Reboot the device after installation.
    • You'll be asked to remove USB drive and press ENTER.

Custom Storage Layout

  • First Reformat all the drives (should result in free space after reformat).
  • Select a drive and choose Add GPT Partition on the free space and select a partition for /boot and give at-least 30G size and use ext4 format.
  • Create another partition with at-least 50GB for /home partition. This helps isolate the operating system drive from your data drive.
  • Optionally, create another partition for /files partition. This will serve as the folder for File Server process, to share data within local network.
    • If you have multiple drives, you can dedicate one drive for this, so that it's easy to migrate later.
  • Use remaining space for / partition.

SSH Setup

The first thing you should do after installation is to update repos and upgrade packages:

sh
# You'll be prompted for password to gain sudo access
sudo apt update && sudo apt upgrade

The OpenSSH should be already installed on the server, but it may not be enabled by default. But before you enable it, you must secure the server by disabling root login. To do so, edit the SSH config present at /etc/ssh/sshd_config:

sh
# Edit using `sudo vi /etc/ssh/sshd_config`
Port 22
ListenAddress 192.168.1.100
PermitRootLogin no

Enable and restart SSH service using:

sh
# Gives current status
sudo systemctl status ssh

# Enable SSH service (to start automatically after each boot)
sudo systemctl enable ssh

# Restart SSH service
sudo systemctl restart ssh

# Check current status after restart
sudo systemctl status ssh

Since you've imported GitHub SSH keys, you should now be able to SSH into homeserver from your Mac machine.

Post-installation Setup

The OS installation is completed, but you'll need other packages and tools to make proper use of the home server. For this post-installation setup, SSH into the homeserver from MacOS device using:

sh
ssh piratedev@192.168.1.100

Disable Ubunto Pro Advertisement messages

Reference Docs

sh
# Check current APT News status
sudo pro config show apt_news

# Disable APT News
sudo pro config set apt_news=false

# Disable Pro messages from APT
mkdir -p ~/docs && sudo mv /etc/apt/apt.conf.d/20apt-esm-hook.conf ~/docs/

# Disable Pro messages from MOTD
sudo cp /var/lib/update-notifier/updates-available ~/docs/
sudo vi /var/lib/update-notifier/updates-available
# Remove unnecessary lines

Enable Firewall

  • Get the current status of Firewall and enable it using:
sh
sudo ufw status verbose
sudo ufw enable
  • Allow all traffic from IPs within local network using:
sh
# This allows all traffic within local network
sudo ufw allow from 192.168.1.0/24
  • Check status again using sudo ufw status verbose.

Install Python

Python 3 is already available on Ubuntu server, but it's managed by apt package manager. So it won't let you install pip packages directly without using a virtual environment. So in order to install Python packages, install them using apt install python3-package foramt.

DO NOT upgrade to latest version of Python to avoid issues.

sh
sudo ln -s /usr/bin/python3 /usr/local/bin/python

Install Node and Yarn

Here are the steps for current verion v22 from this official page.

sh
# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# in lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"

# Download and install Node.js:
nvm install 22

# Verify the Node.js version:
node -v # Should print "v22.14.0".
nvm current # Should print "v22.14.0".

# Download and install Yarn:
corepack enable yarn

# Verify Yarn version:
yarn -v

Install Java and Scala

Reference Doc

Install Java first:

sh
sudo apt install openjdk-11-jdk -y

Download and Install Scala 3:

sh
curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && ./cs setup

Add symlinks:

sh
sudo ln -s ~/.local/share/coursier/bin/scala /usr/bin/scala
sudo ln -s ~/.local/share/coursier/bin/scalac /usr/bin/scalac
sudo ln -s ~/.local/share/coursier/bin/amm /usr/bin/amm

Confirm installation:

sh
scala --version

Configure Git CLI

  • Execute following commands:
sh
git config --global user.name "Pirate Developer (homeserver)"
git config --global user.email "57877111+PirateDevCom@users.noreply.github.com"

Create RSA Keys

sh
ssh-keygen -t rsa -b 4096
# Give a passphrase when prompted

Setup SSH Agent

Add following line to ~/.profile to start SSH Agent on login:

sh
eval "$(ssh-agent -s)"

Execute the following command once and set the environment variables from the output message:

sh
ssh-agent -s

Then execute the following command to your SSH Key to the SSH Agent:

sh
ssh-add
# Enter passphrase when prompted

Upload SSH Key to GitHub

  • Copy the generated public key to clipboard:
sh
cat ~/.ssh/id_rsa.pub

Configure Personal Docs

Configuring the personal docs (this repo) will make it accessible as a website within local network.

Clone GitHub repo:

sh
mkdir ~/github && cd ~/github && git clone git@github.com:PirateDevCom/personal-docs.git

Install dependencies and start local server as a background process:

sh
cd ~/github/personal-docs && yarn install && nohup yarn docs:dev --host > /tmp/vitepress.log 2>&1 &

In order to run the web server as a service, create a service file using:

sh
# sudo vi /etc/systemd/system/piratedocs.service
[Unit]
Description=PirateDev Docs Server
After=network.target

[Service]
Type=simple
User=piratedev
WorkingDirectory=/home/piratedev/github/personal-docs
ExecStart=/home/piratedev/.nvm/versions/node/v22.14.0/bin/node /home/piratedev/.nvm/versions/node/v22.14.0/bin/yarn docs:dev --host
Restart=always
RestartSec=5
Environment="PATH=/home/piratedev/.nvm/versions/node/v22.14.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Environment="NODE_VERSION=22.14.0"
StandardOutput=append:/var/log/vitepress.log
StandardError=append:/var/log/vitepress.log

[Install]
WantedBy=multi-user.target
  • Enable and start the service using:
sh
sudo systemctl enable piratedocs
sudo systemctl start piratedocs

You should now be able to access the website at http://192.168.1.100:5173/

Optional: Install Samba (File Server)

To setup homeserver as a file server accessible from Apple's Files app, you'll need to install and configure Samba:

sh
sudo apt install samba -y

If you had followed the steps properly, you would have a /files partition dedicated for file serving. Create a folder inside it for connecting to Samba:

sh
sudo mkdir /files/icedrive
sudo chmod 777 /files/icedrive
sudo chown piratedev:piratedev /files/icedrive

Configure Samba by editing /etc/samba/smb.conf file:

sh
# Edit using `sudo vi /etc/samba/smb.conf`
[IceDrive]
    path = /files/icedrive
    browseable = yes
    read only = no
    guest ok = no
    create mask = 0666
    directory mask = 0777

Create Samba User:

sh
sudo smbpasswd -a piratedev
# Enter a password when prompted

Restart Samba Service:

sh
sudo systemctl restart smbd

At this point, you should be able to connect to the homeserver from Files app remotely.

Help

Debug SSH connection issues

To confirm that SSH service is listening on Port 22, use:

sh
sudo ss -tulpn | grep :22
# This should return something like this:
# tcp   LISTEN 0      4096           192.168.1.100:22         0.0.0.0:*    users:(("sshd",pid=1390,fd=3),("systemd",pid=1,fd=92))

From MacOS, check if the host is reachable by pinging it:

sh
ping 192.168.1.100

If ping works but SSH says Connection Refused, it's mostly due to some issue with Homeserver hardware components. You should keep trying until it works. A couple of restarts may work sometime.

GitHub SSH Keys

In case you forgot to download GitHub keys during installation or if you deleted ~/.ssh/authorized_keys by mistake, you can re-download them using:

sh
wget https://github.com/PirateDevCom.keys
mv PirateDevCom.keys ~/.ssh/authorized_keys

Delete Firewall rules

If you need to delete existing firewall rules, you need to first list them as numbered ones:

sh
sudo ufw status numbered

Use the number against the rule to be deleted and use:

sh
sudo ufw delete [RuleNumber]

Check status again using sudo ufw status verbose.

Upgrade distribution

To upgrade Ubuntu itself, use:

sh
sudo do-release-upgrade