• 1 Post
  • 19 Comments
Joined 3 years ago
cake
Cake day: December 12th, 2023

help-circle


  • Aah you did mention that, my eyes just decided to skip that when I read your post.

    This reminds me of another issue I ran into but I use Alpine Linux so I don’t know if it’s a distribution specific issue. I’ll share the issue and workaround solution anyways as something to consider.

    Networking on Alpine Linux is controlled by a process called networking and for reasons I don’t understand and can’t see by any logs, it just stops working. I can’t ssh or access the reverse proxy port. I don’t remember if ping was working or not as it’s been a while since I dealt with it now.

    My work around was to have a script on my server ping a known location and restart networking if it couldn’t ping out. If a second ping after restarting the process failed, it would then restart the device. This script would run every 15 minutes.

    It’s a bandage solution that doesn’t solve the problem but it does keep my server running. However it seems like pings still work with your server so you might need to get creative in how you test your server’s connectivity.


  • It sounds to me like ssdh may have stopped working. That may explain why you can’t ssh into your server but pings still respond. I have a Raspberry Pi4 and a Pi5 and have had similar issues in the past.

    I would probably approach this issue by writing a small script that checks every so often if the process sshd is still alive and if not restart sshd. Maybe SystemD can so something similar but I am not familiar with SystemD.

    Edit: A quick and simple script looks like this

    #!/bin/sh
    
    # Check if `sshd` process is running; If not running, `pgrep` returns
    # an exit status of '1' and restarts `sshd`
    pgrep 'sshd' > /dev/null || systemctl restart sshd
    

    Make the script executable with chmod +x /home/user_name/sshd_check

    Add the following line to /etc/crontabs/root to run the script every 15 minutes

     */15    *       *       *       *       /home/user_name/sshd-check
    

    I don’t use SystemD but I am pretty sure systemctl restart sshd is correct, otherwise it can be changed to whatever your operating system uses to control services



  • I tried what you said. I sent a ping from my computer to the server and this was the output of nft monitor trace:

    trace id 1d01c81e ip ping_trace prerouting packet: iif "eth0" ether saddr b0:7d:64:e8:8f:3c ether daddr d8:3a:dd:de:28:99 ip saddr 192.168.40.201 ip daddr 192.168.40.203 ip dscp cs0 ip ecn not-ect ip ttl 64 ip id 65074 ip length 84 icmp type echo-request icmp code 0 icmp id 35586 icmp sequence 0 
    trace id 1d01c81e ip ping_trace prerouting rule icmp type { echo-reply, echo-request } meta nftrace set 1 (verdict continue)
    trace id 1d01c81e ip ping_trace prerouting policy accept 
    trace id 1d01c81e inet filter input conntrack: ct direction original ct state new ct id 271120081 
    trace id 1d01c81e inet filter input packet: iif "eth0" ether saddr b0:7d:64:e8:8f:3c ether daddr d8:3a:dd:de:28:99 ip saddr 192.168.40.201 ip daddr 192.168.40.203 ip dscp cs0 ip ecn not-ect ip ttl 64 ip id 65074 ip protocol icmp ip length 84 icmp type echo-request icmp code 0 icmp id 35586 icmp sequence 0 
    trace id 1d01c81e inet filter input rule ip protocol icmp icmp type { echo-reply, destination-unreachable, echo-request, time-exceeded, parameter-problem } accept comment "Accept ICMP" (verdict accept)
    

    I sort of get what’s happening and it looks like the ping request has been accepted.

    From my computer when I send a ping it shows:

    15:55 dell:/tmp/ $ ping -c1 192.168.40.203
    PING 192.168.40.203 (192.168.40.203): 56 data bytes
    
    --- 192.168.40.203 ping statistics ---
    1 packets transmitted, 0 packets received, 100% packet loss
    

    So even though it’s being accepted, I still get nothing going back to my computer, at least that’s how I understand it.


  • I tried your suggested rules and still nothing

    I went a step further and simply enabled all incoming connections with:

    table inet filter {
    	chain input {
    		type filter hook input priority 0; policy allow;
    	}
    }
    

    Again I can connect with SSH and WireGuard but I still can’t ping my server. If I restore to my last backup with iptables, I can get a response from ping again.

    I also tried directly translating the rules from iptables with:

    iptables-save > /tmp/iptables.dump
    iptables-restore-translate -f /tmp/iptables.dump > nftables.dump
    

    and adding the rules:

    #!/usr/sbin/nft -f
    
    define WIREGUARD_PORT = 51820
    define WIREGUARD_ADDRESS = 10.0.0.0/24
    define SSH_PORT = 5025
    define SSH_ADDRESSES = { $WIREGUARD_ADDRESS . $SSH_PORT, 192.168.40.204 . $SSH_PORT }
    define PUBLIC_PORTS = { 5050 }
    
    table inet filter {
            chain input {
                    udp dport $WIREGUARD_PORT accept \
                    comment "Accept WireGuard connections"
    
                    ip saddr . tcp dport $SSH_ADDRESSES accept \
                    comment "Accept SSH connections from known devices or WireGuard"
    
                    tcp dport $PUBLIC_PORTS accept \
                    comment "Accept public connections"
    
                    icmp type echo-request limit rate 5/second burst 10 packets counter accept
                    icmp type echo-request limit rate 30/minute burst 120 packets counter accept
                    icmp type echo-request limit rate 1/minute burst 2 packets counter log prefix " PING-PONG-FLOOD "
                    icmp type echo-request counter drop
    
                    icmp type destination-unreachable counter accept
                    icmp type time-exceeded counter accept
                    icmp type parameter-problem counter accept
                    icmp type echo-request counter accept
            }
            chain forward {
                    icmp type destination-unreachable counter accept
                    icmp type time-exceeded counter accept
                    icmp type parameter-problem counter accept
                    icmp type echo-request counter accept
            }
    }
    

    and still no ping from my server…

    I will agree, the documentation for nftables is just not as accessible or consistent as iptables. It’s a bit frustrating.



  • That’s fair

    I have a very different view on data, physical property and familial relationships. Everything is temporary to me and I’ve prefer my stuff to be reused rather than act as an archive to my own life.

    My pictures, music and technology related projects are just for myself. Anything I wish to share after my death is stored on an unencrypted drive connected to a Raspberry Pi that acts as my web facing server that serves only static data. It’s mainly a bunch of wikis, linux/shell scripting references, some of my git repositories, some survival type ebooks and some other random stuff.

    I’ve lost data multiple times throughout my life so I know I’d be disappointed but not sad if I lost all my data one more time. I do have multiple backups now so I at least have some data resilience compared to the past.


  • I am the same way. My backup is on the other side of the room. If my house goes up in flames, I’ll have bigger issues to deal with, like my house going up in flames.

    Data is just data. It wasn’t there when I was born and it’s all encrypted now so when I die, I want the next person to wipe it clean and use the hardware for themselves.

    Having a backup is convenient but it’s not the end of the world if I lose it.


  • I’ve been trying to find a balance between what I currently own, what I can do with it and using as little outside resources to self host. I’m also cautious about what has access to the internet which limits what I host.

    I have two Raspberry Pi’s. One is only accessible through my home’s local network through my WiFi Extender network. That WiFi extender also helps hide my personal network from my ISP which see’s everything connected to the main modem/router. This Pi is strictly for my IoT devices.

    My other Pi is a web facing server. It has Caddy and Kiwix. It hosts a static blog, simple file server which servers my git repositories, some survival ebooks, plain text recipes and a bunch of programming related resources. Kiwix has a bunch of wikis, Wikipedia to survival stuff, vegetarianism, coding stuff and things surrounding those topics generally. I generally avoid anything that uses databases because I don’t have the energy to learn, maintain and protect that. Plus I have a focus on small, low powered minimalism.

    Those Pi’s both use Alpine Linux. I chose Alpine because it’s small and uses less common tools. doas over sudo, OpenRC over SystemD, and Musl over glibc. It’s a bit of security by obscurity but I’ve also made efforts to harden Alpine Linux itself too. I’ve disabled a lot of kernel modules, made strict firewall rules, and made sure to include the use of apparmor. I’ve also written all my backup solutions and maintenance scripts myself and tested as thoroughly as I am capable of. I also avoid complexity by keeping things as minimal as possible to reduce the surface area of any possible attacks.

    I use podman containers to keep everything in the userspace. Caddy is my reverse proxy which means only one port is freely accessible to the internet. I also use a wildcard cert to obscure my publicly available information and use an uncommon port instead of the standard 80/433 ports. Because of the wildcard cert/uncommon port, I receive no bot traffic so I don’t feel the need to use Cloudflare or Anubis. I’m hidden enough and the only people I want on my blog/file server/Kiwix wiki’s are close friends.

    For SSH, I’ve hidden all those behind WireGuard so the second open port to my web server looks hidden from scanners (at least that’s how I understand it). I used to use a custom port which only got about 15 hits a week from bots appearing from the Netherlands. That number has since dropped to zero after setting up WireGuard. I’m sure the bots are attempting but they aren’t making any appearances in my logs and that’s good enough for me.

    I’m happy more talk about security has been popping up lately. So many websites focus on getting things running and just don’t take any time to talk about security. I had to switch from docker to podman because docker had so much control over iptables that never got reported to ufw which was a concern for me. That point is rarely talked about since it’s so easy to copy and run a docker-compose.yml file.


  • I often see claims that Alpine linux is just for embedded systems. I wanted to highlight to other people that there is far more to Alpine than embedded systems or being used for containers.

    It’s mininal like void but still very flexible and capable if people are willing to work with Musl, BusyBox or OpenRC. It’s a nice option for anyone who has issues with SystemD or may want to depend less on GNU tools.

    Like any distribution, it doesn’t fill everyone’s wants or needs but it seems to have grown more than serving just embedded systems.



  • Aaah that’s good to know. I’ve seen HAproxy mentioned before and this was the first time I looked at it.

    I am happy I went with Caddy because networking is not my strength and Caddy is quite simple in comparison to other reverse proxies. Nginx config files will forever look like scribbles to me.

    I don’t know about the limitations of using an uncommom port though because my needs are quite small and obscure by design. I do wonder if other people could benefit from using wildcard certs + uncommon ports. Watching bots/scrapers drop to zero attempts and stay zero has been really satisfying and I haven’t had the desire to use outside services like Anubis or Cloudflare.

    I know someone out there with itchy fingers is ready to warn that obscurity isn’t security and I wouldn’t deny that. However, I do believe obscurity layered with security is valid as long as security takes the main focus.


  • For the past year I’ve been learning to self host minimally on a used Raspberry Pi 5. I do have a Pi 4 as well but that’s dedicated to HomeAssistant for the small handful of lights and switches it controls.

    Both Pi’s run Alpine Linux with Podman containers. For my Pi 5 server it runs Caddy as my reverse proxy/SSL cert handler plus another contained for Kiwix. It’s super simple. Caddy also has a basic file server for me to host my git repositories as well as hosting my static site.

    The static site is based off a script I found called BashWrite but it hasn’t been updated in a year so I decided to add some of my own changes to it here. I also fixed up some of the English grammar since the original creater wasn’t an English native speaker.

    I’m still focusing on the background stuff but I’ve put a lot of effort into security and hardening. I’ve written all the maintenance (backup, keep-alive, updating) myself using POSIX portable scripts which can all be found on my codeberg page. It’s been a long process but I’m nearly there. I just have to switch from iptables to nftables and add secrets to my Caddyfile configuration to hide important keys that are currently sitting as plain text. After that I can focus on my blog/static site.

    Since I’m not doing this for a business, I’ve decided to use a wildcard domain for my SSL cert plus an uncommon port as a low effort way to hide myself from bots/scraper. Also I set up Wireguard infront of my SSH connection to also hide from bots. My log activity only shows my own activity which is comforting to know, especially since I’ve seen just how active bots and scrapers are in comparison to a year ago when I was just getting started and beginning to learn things.

    It’s really cool to see another minimal project like this and I think it’s refreshing to see. A lot of the times I see people with dozens on intensive services running and I feel a bit out of place with my scaled down self hosted project.

    My only question about your setup is about HAproxy. How important is a load balancer for your site? I don’t think I will need one for myself since the traffic will mostly be for myself and a few people I know personally but I am still curious about how it works and how effective it is for your setup.




  • This was a number of months ago so I doubt it would be remembered anywhere at this point. After that, a number of posts I commented in were also removed as well. It was very confusing because everything seemed appropriate for the community. I do look forward to seeing how this community grows/changes now.

    I’ve taken a very minimalist approach to self-hosting but I’ve given extra attention towards security. I feel like security doesn’t get talked about as much as it could be. It’s especially important these days with bots roaming around everywhere.

    I also use some unconventional methods that I’d like to share (layering security with obscurity with a focus on security first). It’s not a one size fits all solution but I can stay private while exposing my server with minimal tools. It works for me though and my logs haven’t shown any outside activity besides my own.


  • I stopped posting and commenting on this community because things kept getting deleted even though it was all very clearly about self-hosting. It was very disappointing because I spent a lot of time on my contributions. One post I made a while ago was about self-hosting security and had tons of activity only for all that information to be removed over rule 3. Very confusing and disappointing.

    I’m interested in seeing how the vibe around here changes going forward. Maybe I’ll be less cautious about participating.


  • I just use SSH+Rsync for everything. I traded two-way sync for minimalism and reliability. I’ve had nothing but headaches with anything else, especially Syncthing.

    My Computer and both Raspberry Pi servers both run Linux and I have Termux installed on my Android phone so OpenSSL and Rsync are easily available.

    I made a script that runs Rsync commands from files containing all the information which easily swaps source/target files so I can easily transfer in both directions with a simple command line option. It’s reliable and simple and I’ve had a lot less headaches troubleshooting the rarely occurring issues.


  • It’s mind blowing to me that anyone wants to live forever in this life or the next.

    From my experiences, many people that are afraid of death are also extremely unhappy being alive in the first place. They are constantly struggling with the fear of their life coming to an end that they miss being able to be in the moment. That’s stressful as fuck.

    Everyone poops. Everyone dies. That’s just a part of life. Not a whole lot in this universe has the opportunity to see beautiful things and experience emotions.

    Sadly, people who are afraid of death like to make it other peoples problem. Generally, I prefer the company of a pile of shit over those people. A pile of shit won’t think twice about nurturing new life no matter what it is and that’s the kind of vibes I can support.

    Anyways, my retirement plan is still extreme sports. If I’m going to leave life behind, I’m going out in style.