Self-Hosted Infrastructure

Crypto farming. WIP.

These instructions assume you're on a POSIX-compliant operating system. See Installation.

You'll need the following:

  • USB Thumb Drive - 8 GB minimum
  • A machine to download the .iso image. and burn it to the USB thumb drive.
  • Target machine with CPU, RAM, and a Network Interface Card
    • Could even be a Raspberry Pi

Choose Operating System Kernel & User Space

Download the corresponding .iso file.

Burn ISO Image to USB

Shell
lsblk

Your output will look something like this.

NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda           8:0    1  7.5G  0 disk 
├─sda1        8:1    1  2.6G  0 part 
├─sda2        8:2    1    5M  0 part 
├─sda3        8:3    1  300K  0 part 
└─sda4        8:4    1  4.9G  0 part 
zram0       254:0    0    4G  0 disk [SWAP]
nvme0n1     259:0    0  3.6T  0 disk
├─nvme0n1p1 259:1    0    1G  0 part /boot
└─nvme0n1p2 259:2    0  3.6T  0 part /var/log
                                     /var/cache/pacman/pkg
                                     /home
                                     /.snapshots
                                     /
nvme1n1     259:3    0  1.9T  0 disk

The sda storage block is the USB and is highlighted in green above. Modern Linux systems use the sd prefix to indicate 'Storage Device'. a refers to the first detected device.

If you had other external storage devices connected, the letter for your newly connected USB will be different because it was discovered later (sdb, sdc, etc.).

The entries in the tree following sda such as sda1, sda2 etc. indicate disk storage partitions.

Unmount all partitions.

Shell
sudo umount /dev/sda1 /dev/sda2 /dev/sda3 /dev/sda4
Shell
# Change location to whereever your .iso file is located
sudo dd if=~/Downloads/ubuntu-24.04.1-live-server-amd64.iso of=/dev/sda bs=4M status=progress oflag=sync

After completion:

Shell
sudo eject /dev/sda

Set up server

Flash OS from USB to Server Hardware

Boot into USB from BIOS.

After installation completes, log in to your machine.


Shell (Server)
sudo apt update && sudo apt upgrade -y && \
sudo apt install openssh-server net-tools && \
sudo systemctl enable ssh && \
sudo systemctl start ssh && \
sudo systemctl status sshd # Verify service running

Configure SSH for External Access (WIP)

Same Network

Shell (Server)
ip addr
Shell (Client)
ssh username@<machine_ip_addr>
# ssh user@10.0.1.2

Different Networks

Set up port forwarding from router.

Find public IP address

Shell (Server)
curl ifconfig.me

Harden SSH Security:

Disable root login in /etc/ssh/sshd_config.

Shell (Server)
PermitRootLogin no
Port 2222
sudo systemctl restart sshd

Install Nix

Terminal
# Answer 'y' for all questions
sh <(curl -L https://nixos.org/nix/install) --daemon --yes
Terminal
exit

Log in again.

Shell (Server)
nix-env -iA nixpkgs.zellij
Shell (Server)
zellij
Shell (Client SSH)
zellij attach

Optional

Shell (Server)
nix-env -iA nixpkgs.{git,gh,stow,zsh,ripgrep,fd,yazi,eza,bat,cowsay,cmatrix,lolcat,nyancat,fastfetch}
}

Install Oh My Zsh, a framework to easily customize the look and feel of zsh.

Shell (Server)
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Install PowerLevel10K, a theming system for the Oh My Zsh framework.

Shell (Server)
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k;

Change value of ZSH_THEME in ~/.zshrc:

sed -i 's/^ZSH_THEME=".*"/ZSH_THEME="powerlevel10k\/powerlevel10k"/' ~/.zshrc; source ~/.zshrc

If the Powerlevel10k configuration menu doesn't start, do:

Shell (Server)
p10k configure

Install and configure useful zsh plugins.

Shell (Server)
# Autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# Syntax Highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Shell
sed -i 's/^plugins=(.*)$/plugins=(git zsh-autosuggestions zsh-syntax-highlighting web-search)/' ~/.zshrc
Shell (Server)
cat << 'EOF' >> ~/.zshrc
 
# Aliases
alias l='eza -lh --icons=auto'
alias ls='eza --icons=auto --sort=name --group-directories-first'
alias ll='eza -lha --icons=auto --sort --group-directories-first'
alias ld='eza -lhD --icons=auto'
alias lt='eza --icons=auto --tree'
alias y='yazi'
alias mkdir='mkdir -p'
 
EOF
Shell (Server)
source ~/.zshrc

Install Pnpm

Shell (Server)
curl -fsSL https://get.pnpm.io/install.sh | sh - && \
  if [ -n "$ZSH_VERSION" ]; then source ~/.zshrc; elif [ -n "$BASH_VERSION" ]; then source ~/.bashrc; fi
Shell (Server)
pnpm env use 22.11.0 --global

Install Playwright

Shell (Server)
pnpx playwright install --with-deps

Set up GitHub Actions Runner

Visit github.com/organizations/cuhacking/settings/actions/runners/new for steps.

Optional

Shell (Server)
nix-env -iA nixpkgs.git nixpkgs.gh nixpkgs.stow nixpkgs.zsh nixpkgs.ripgrep nixpkgs.fd nixpkgs.yazi nixpkgs.eza nixpkgs.bat nixpkgs.cowsay nixpkgs.cmatrix nixpkgs.lolcat nixpkgs.nyancat nixpkgs.fastfetch
Shell (Server)
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Shell (Server)
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k;

Open ~/.zshrc and change the the value of ZSH_THEME:

Shell (Server)
vim ~/.zshrc
ZSH_THEME="powerlevel10k/powerlevel10k"
Shell (Server)
p10k configure
Shell (Server)
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
~/.config/.zshrc
plugins=(git zsh-autosuggestions zsh-syntax-highlighting web-search)
 
# Aliases
alias l='eza -lh --icons=auto'
alias ls='eza --icons=auto --sort=name --group-directories-first'
alias ll='eza -lha --icons=auto --sort --group-directories-first'
alias ld='eza -lhD --icons=auto'
alias lt='eza --icons=auto --tree'
alias y='yazi'
alias mkdir='mkdir -p'
Shell (Server)
source ~/.zshrc