Skip to content

Securing SSH without fail2ban on tiny RAM

VPS Hosting by tallinnying 24 replies 3.3K views
#11

tallinnying said:
Auth.log was 200MB in a week

Logrotate, my friend. Not everything needs a daemon.
/etc/logrotate.d/auth
with
size 10M
and
rotate 3
. Been doing this since before fail2ban existed.

Port knocking in 2009 needed kernel patches or userspace pcap. Now it's in repos everywhere but the fundamental tradeoff hasn't changed: security through obscurity plus inconvenience.

SPARCstation 20, still serving HTTP
#12

Sshguard is good! I forget this. The python of fail2ban is problem for me, very slow start. In Argentina the connection to update repos is sometimes bad, and fail2ban need many dependencies.

I use now only iptables + knockd in HostHatch. But sshguard maybe better for client who no want complexity of knocking. I will test.

#13

Our nephew looked at sshguard. He said still needs read logs, still needs run something. The iptables rule runs once and done. For bakery server this is enough, we only ssh maybe twice a month when LocalTech needs fix something.

I asked about log size, he said he set logrotate already. Problem solved before it start.

#14

tallinnying said:
Auth.log was 200MB in a week

This is why I just disable password auth and move on. Key only, no root login, done. My 256MB boxes at CloudCone and wherever else, never run fail2ban or anything. The bot traffic still hits but they can't get in, logs or no logs.

Port knocking I tried, got locked out twice because mobile IP changed mid-knock. Never again.

world record: 4min Arch install
5 #15

I run a 96MB box in Riga, OpenVZ from some dead provider I got for $4/year. No iptables recent module available, kernel too old. I use denyhosts, remember that? Python 2, barely maintained, but it works. Parses auth.log, writes to hosts.deny.

Tcp_wrappers still functions on this ancient template. Richard7 would approve.

worst bandwidth, best stories
#16

svendeal said:
Key only, no root login, done.

This is the baseline. Everything else is optional. I manage 40 client servers in Madrid, mix of KnownHost dedicated and random VPS. My standard deploy: key auth, nonstandard port, firewall drop all else. fail2ban only on the 2GB+ boxes where clients demand it for compliance theater.

The 128MB cases I tell them to use CloudFlare tunnel or not host there.

swimming upstream since 2019 🐟
#17

Nonstandard port cuts bot traffic by 99% without any software. I track this myself, logs to my own InfluxDB. Port 22 gets thousands of attempts daily. Port 4422 gets maybe ten, all targeted not spray-and-pray.

Memory cost: zero. Security gain: marginal but noise reduction massive. I bill hourly in pesos, every MB of RAM saved is money.

not your keys, not your coins
3 #18

carlos2 said:
Nonstandard port cuts bot traffic by 99%

Security through obscurity they said. But honestly for tiny boxes the noise reduction matters. My syslog daemon was CPU bound parsing auth entries before I moved ports.

Still use iptables rate limit on top, because targeted scans exist. Layered, cheap, good enough.

#19

What about ufw with limit? It generates similar iptables rules but easier syntax.

ufw limit 22/tcp
does the recent module setup automatically. On Ubuntu the memory cost is just ufw itself, already running.

Not for 128MB probably, but for 512MB+ it's manageable and you get IPv6 rules too.

9 #20

man34 said:
It generates similar iptables rules but easier syntax.

ufw is python3 on Debian. On my box it takes 15 seconds just to
ufw status
. The rules it generates are fine but the tool itself is heavy for this use case.

I just learned

iptables-save
and
iptables-restore
, put my rules in
/etc/iptables/rules.v4
, load at boot with a tiny systemd service I wrote. No python, no persistent process.

builds at 3AM, sleeps at noon

Post a reply

You need an account to reply. Log in or register to join the conversation.

Post reply Preview Save draft