this post was submitted on 23 Aug 2023
14 points (100.0% liked)

Selfhosted

40152 readers
512 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

Hi, I'm setting up a public wiki using mediawiki and I'd like some help ensuring the server and mediawiki is safely setup before I start sharing it publicly. I installed it on Vultr using the mediawiki app from the Vultr Marketplace. Are there any things I should ensure before publicly sharing the link?

Some things I've done so far:

  • I disabled password login to the server so its only possible to login via ssh

  • I made it so I have to approve of any edits to the wiki

  • I still haven't enabled uploads of files because I want to ensure I only allow jpeg\png uploads.

I'm relatively new to running servers so any tips are highly appreciated.

top 21 comments
sorted by: hot top controversial new old
[–] mudeth@lemmy.ca 13 points 1 year ago (1 children)

Install fail2ban. Prevents brute force access to your server. The defaults should be fine.

[–] xnx@lemm.ee 2 points 1 year ago

Done. Thanks!

[–] saint@group.lt 5 points 1 year ago (1 children)

Get some WAF for the public facing app, maybe at least https://github.com/nbs-system/naxsi .

[–] xnx@lemm.ee 1 points 1 year ago (1 children)

ELI5? 😅

The install section of naxsi is a whole lotta stuff I've never touched before

[–] saint@group.lt 1 points 1 year ago (1 children)

sorry, this is kinda like a firewall, but protecting websites, so many vulnerabilities are filtered out. it does not protect you 100% percent (nothing does). it might be hard to setup, in that case there is an option to use waf as a service, i.e. - cloudflare has such offering, maybe there are others as well. i have looked into vultr - they seem to offer only a "usual" type of firewall, not http/application based.

[–] xnx@lemm.ee 1 points 1 year ago (1 children)

Ah ok thanks for the info! Do you know if vultrs firewall would make installing fail2ban redundant?

[–] saint@group.lt 1 points 1 year ago (2 children)

if you configure ssh access only from your home ip - then fail2ban is not needed.

[–] Haui@discuss.tchncs.de 1 points 1 year ago (2 children)

But if your home ip ever changes, you‘re fucked. I would never do that. Pubkey is the way.

[–] saint@group.lt 2 points 1 year ago (1 children)

usually i add more than 1 ip and also vultr firewall can be managed to change ip. tailscale can be used as well. there are options!

[–] Haui@discuss.tchncs.de 2 points 1 year ago

That’s good! Had me worried there.

[–] SheeEttin@lemmy.world 2 points 1 year ago (1 children)

Method of authentication doesn't matter if there's a pre-authentication vulnerability: https://thehackernews.com/2023/02/openssh-releases-patch-for-new-pre-auth.html

Instead of exposing multiple services, I would recommend just one VPN for remote access. Less attack surface.

[–] Haui@discuss.tchncs.de 1 points 1 year ago

Thats how I do it. But I also have physical access so if the vpn fails I don’t get locked out.

[–] xnx@lemm.ee 1 points 1 year ago

Oh perfect thanks

[–] Decronym@lemmy.decronym.xyz 4 points 1 year ago* (last edited 1 year ago)

Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:

Fewer Letters More Letters
HTTP Hypertext Transfer Protocol, the Web
HTTPS HTTP over SSL
IP Internet Protocol
SSH Secure Shell for remote terminal access
SSL Secure Sockets Layer, for transparent encryption
VPN Virtual Private Network

4 acronyms in this thread; the most compressed thread commented on today has 8 acronyms.

[Thread #74 for this sub, first seen 23rd Aug 2023, 08:05] [FAQ] [Full list] [Contact] [Source code]

[–] Illecors@lemmy.cafe 1 points 1 year ago (1 children)

I disabled password login to the server so its only possible to login via ssh

Phrasing is a bit strange. Does this mean ssh can only be used to login with a key? If so - great!

Since you're using an "app" - not sure there's much we can help you with. The control has been ceded to the maker of said app.

I would normally set up some limits on the firewall and change the ssh port so logs are less polluted, not sure it's possible for you.

[–] xnx@lemm.ee 1 points 1 year ago (3 children)

Yeah its only possible to login with a key.

What limits would you set on the firewall?

From the bit I've read people usually say changing the ssh port is mostly "security theatre" is this not fully true?

[–] diminou@lemmy.zip 3 points 1 year ago

For the limit : basically you need to ask yourself how many connection someone if able to do in a second to your server. As an example, my limit is always 15. A bit high but I'm sure I'm not blocking a legitimate one (either from myself or someone else)

For the ssh port : it's true, but trust me you'll be happy to change for something random like 5927 because you'll have far less bit trying to connect or probe your ip, thus your logs won't be cluttered!

[–] Illecors@lemmy.cafe 1 points 1 year ago (1 children)

It would be security theatre if it was done for security. I'm not doing it for security, though - it's for my sanity when checking the logs. Unrestricted SSH simply attracts too many bots and the failed logins make it impossible to quickly grasp a picture of what's happening.

In regards to limits - this is my rule file for iptables on my lemmy instance:

*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:LOG_DROP [0:0]
:LOG_ACCEPT [0:0]

-A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -m recent --set --name DEFAULT --mask 255.255.255.255 --rsource
-A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -m recent --update --seconds 600 --hitcount 20 --name DEFAULT --mask 255.255.255.255 --rsource -j LOG_DROP
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -m state --state NEW -m recent --set --name HTTPS --mask 255.255.255.255 --rsource
#-A INPUT -p tcp -m tcp --dport 443 -m state --state NEW -m recent --update --seconds 600 --hitcount 600 --name HTTPS --mask 255.255.255.255 --rsource -j LOG_DROP
-A INPUT -p tcp -m tcp --dport 443 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -j LOG_DROP

-A LOG_ACCEPT -j LOG --log-prefix "[ACCEPTv4]: " --log-level 7
-A LOG_DROP -j LOG --log-prefix "[DENYv4]: " --log-level 7
-A LOG_ACCEPT -j ACCEPT
-A LOG_DROP -j DROP
COMMIT

This is very much a WIP, I'm going to implement some ddos protection as soon as I get some spare time.

[–] xnx@lemm.ee 1 points 1 year ago* (last edited 1 year ago) (1 children)

Could you explain a bit of what these are doing and why you decided on these rules?

Also, isn't bruteforcing an SSH key near to impossible?

[–] Illecors@lemmy.cafe 1 points 1 year ago

There are 2 extra chains - to log a connection and accept it, and to log a connection and drop it. I've only used log and accept for testing.

The default action on input chain is also changed to drop.

SSH port gets connection attempts counted - 20 connections within 10 minutes from the same IP and it goes to log and drop. I could just drop it, but for now I feel immense satisfaction knowing that some bot is waiting for timeout instead of attempting the next username/pass.

I've tried a similar thing with https because lemmy.world was dosing me. It did work, but I've now commented it out since Lemmy software has become more robust. Lemmy.world still sucks from my, as an instance owner, perspective, but it no longer bombards me periodically.

[–] AnonStoleMyPants@sopuli.xyz 1 points 1 year ago

It does not increase security per se but it does limit the amount of bots trying to connect to your server. At least it will make your log a bit less cluttered with random garbage.

Also installing something like fail2ban might be a good idea. Or even better would be to block all ssh connections except from a specific ip address (whitelist). This of course depends whether you can trust your ip to stay the same, or if you can still log in through some other interface if necessary.