Instructions are for setting up my home server on an Seeed Odyssey x86 Blue with Debian 11 Bullseye. The following steps assume the Debian install is already complete.
apt install sudo
/sbin/usermod -aG sudo <username>
sudo nano /etc/apt/sources.list
and addnon-free
aftermain
todeb http://deb.debian.org/debian/ bullseye main
anddeb-src http://deb.debian.org/debian/ bullseye main
sudo apt update
apt install firmware-misc-nonfree
sudo nano /etc/ssh/sshd_config
- Uncomment and set
PermitRootLogin yes
sudo systemctl restart ssh
ssh-copy-id root@<server ip>
ssh-copy-id <username>@<server ip>
Go back and comment out PermitRootLogin
in /etc/ssh/sshd_config
to only allow root login with SSH keys (i.e. prohibit password).
lsblk -f
to view current mounted drives and partitionssudo nano /etc/fstab
and add a line with the UUID, mount point, file system type, options, dump and pass options:UUID=<uuid> /home/user/backup ext4 defaults 0 2
(example of a permanently mounted drive)
sudo apt install exim4-daemon-light
dpkg-reconfigure exim4-config
and setup using the following:
General type of mail configuration: mail sent by smarthost; received via SMTP or fetchmail
System mail name: localhost
IP addresses to listen on for incoming SMTP connections: 127.0.0.1 (leave default)
Other destinations for which mail is accepted: Leave empty.
Machines to relay mail for: Leave empty.
IP address or host name of the outgoing smarthost: smtp.gmail.com::587
Hide local mail name in outgoing mail?: No
Keep number of DNS-queries minimal (Dial-on-Demand)?: No
Delivery method for local mail: mbox format in /var/mail/
Split configuration into small files?: No
sudo nano /etc/exim4/passwd.client
and addsmtp.gmail.com:[email protected]:mypassword
- Send test email using
echo test only | mail -s 'Test Subject' [email protected]
- Logs are located in
/var/log/exim4/mainlog
sudo dpkg-reconfigure -plow unattended-upgrades
to enable unattended upgradessudo nano /etc/apt/apt.conf.d/50unattended-upgrades
and uncomment and specify email address forUnattended-Upgrade::Mail "[email protected]";
.
On step 3, only sudo groupadd apex
is needed to supress an log warning
- Check instructions at duckdns.org (login for specific instructions)
docker volume create <volume name>
for every volume needed- From the backup drive,
cp -r volumes /var/lib/docker/
docker-compose up -d
sudo apt install nut-server
sudo nano /lib/systemd/system/nut-server.service
and add (fixes issue after reboot where nut-server will fail to start)
[Service]
ExecStartPre=/bin/sleep 30
- From the NUT folder on the back up drive,
cp -r * /etc/nut
sudo systemctl restart nut-server
sudo apt install nut-client
- Restore NUT client config files
This is an added layer of security since the server is connected to the same network, via the second NIC port, the cameras reside on which is a separate VLAN with no access to the internet (or any other subnets on the network). This is to allow the Frigate service to directly record from the cameras without having to route through different VLANs (reduces significant overhead on the router).
sudo iptables -A INPUT -i enp3s0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
to allow traffic from established connections (i.e. stateful firewall)sudo iptables -A INPUT -i enp3s0 -p udp -j ACCEPT
to accept UDP traffic for the WebRTC integration in Home Assistant (can further specify UDP ports as well)sudo iptables -A INPUT -i enp3s0 -p udp --dport 123 -j ACCEPT
to accept NTP requests for NTP serversudo iptables -A INPUT -i enp3s0 -p all -j DROP
to drop all inbound traffic on enp3s0 IPv4sudo iptables -vL
to make sure the rules were added
Docker adds a rule to the PREROUTING chain on the nat table which can be viewed using sudo iptables -vL -t nat
. This will redirect traffic that will be delievered locally on the host to the DOCKER chain on the filter table (where we added the rules above), effectivelly bypassing the rules we just added. As such, the same rules above need to be added to the DOCKER-USER chain per the Docker documentation (don't add user rules directly to the DOCKER chain).
sudo iptables -A DOCKER-USER -i enp3s0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A INPUT -i enp3s0 -p udp --dport 123 -j ACCEPT
sudo iptables -A DOCKER-USER -i enp3s0 -p all -j DROP
sudo iptables -vL
to make sure the rules were added
sudo ip6tables -A INPUT -i enp3s0 -p all -j DROP
to drop all inbound traffic on enp3s0 for IPv6sudo ip6tables -vL
to view iptables to make sure changes were made
sudo apt install iptables-persistent
to save the iptables to persist between restarts- Switch to root,
/sbin/iptables-save > /etc/iptables/rules.v4
and/sbin/ip6tables-save > /etc/iptables/rules.v6
after modifying rules to update persistant tables.
sudo apt install rsync
sudo crontab -e -u root
- Add cronjobs, ex:
30 1 * * * rsync -a /home/user/docker/docker-compose.yml /home/user/backup/home-server-1/docker
(occurs at 1:30 am every day)
docker-compose pull
docker-compose up -d