TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: A proactive way of securing your Linux server

143 pointsby prashantgupta24almost 5 years ago

35 comments

kelnosalmost 5 years ago
This just feels like moving ssh auth to another port, using an obscure &quot;authentication format&quot; that nearly no one uses.<p>If you&#x27;re using pubkey or certificate auth, have disabled password auth, and restrict what users are allowed to ssh in, this just feels like added complexity and points of failure (not to mention a possible source of crypto vulnerabilities) with not much added benefit.<p>Having said that, it&#x27;s a cool project in general, and I feel like it could be useful to dynamically manage access to large groups of servers (perhaps not just ssh; you could use it to manage access to https interfaces or other things). Then again, if you have a large group of servers, you should have those ports blocked to the world and only allow access through a VPN and&#x2F;or jump boxes.
评论 #24369681 未加载
评论 #24369380 未加载
评论 #24369958 未加载
thatha7777almost 5 years ago
This is very similar to port knocking, although more complicated. Although a proper JWT token is “more secure” than a sequence of 0-65535 integers, I contend that having complicated and&#x2F;or unvetted logic as your first line of defense is more problematic than secure.
评论 #24368497 未加载
评论 #24368801 未加载
评论 #24369654 未加载
ryanjkirkalmost 5 years ago
Setting this up makes much less sense than setting up a tested vpn, such as wireguard or open, or even a persistent ssh tunnel using autossh to your home rpi.<p>I would never allow my prod systems to be potentially exposed by an api that runs as root. (And the documentation is incorrect on that; it should run as an unprivileged user with sudo privs to only run a wrapper script that runs firewall-cmd).<p>This also makes little sense in the context of configuration management, which should be enforcing a static set of iptables rules.
评论 #24368206 未加载
nyx_almost 5 years ago
I like to run fail2ban in conjunction with a non-standard SSH port on which only public key auth is available.<p>This way, most of the junkware that does rude things to port 22 is banging on a closed door; the slightly more effective junkware that actually finds the SSH port gets banned immediately, because I know anyone trying to log in with a password is full of it.
评论 #24367938 未加载
评论 #24369560 未加载
wrkronmilleralmost 5 years ago
I usually just disable password auth and update regularly, when I have an SSH server open to the internet.<p>Short of an 0day in the SSH service, I expect brute forcing the private key(s) to take longer than I have years to live.
评论 #24367447 未加载
评论 #24367465 未加载
fl0wenolalmost 5 years ago
The idea is better than port knocking, in the sense that you take active action to associate your host with the server, but there&#x27;s a few issues.<p>* Something this simple shouldn&#x27;t need k8s, unless it was intended as an exercise by the developer for that reason<p>* It combines the idea of using a non-standard port with certificate based authentication, which you can already do with SSH-- it&#x27;s functionally the same with more steps<p>Hypothetically, this approach can be more powerful as a centralized service running elsewhere, (i.e. cloud, your remote DC) and used for a whole bunch of jump boxes and end-users. End-users could run a &quot;check-in&quot; script wrapping around SSH that notified the service that a user was imminent, and then could check the server to see if 1) The bearer token is accepted for the destination server 2) That the destination server checked in, saw the new incoming request, and has already opened the port -- And then proceeds to run the SSH command if all is well, or fails with appropriate error.
joana035almost 5 years ago
Nope nope nope.<p>This has serious quality issues and any competent and nice sysadmin should say _nope_ to run this in any serious environment, for your own good ;-)<p>IP addresses are just strings? At least parse&#x2F;validate for IPv4&#x2F;IPv6.<p>Why yet another database? Can&#x27;t the rules be loaded from the running system?<p>Why not just ipset-persistent + knockd + portsentry? I know it is easy to get overexcited with a new pet project, but just be careful to not put this kind of stuff in a production system kidos.
评论 #24369562 未加载
yabonesalmost 5 years ago
I don&#x27;t like this approach very much because it&#x27;s much more complicated than it would have to be. Security is about layers, and this is essentially one layer that acts as the sole guardian for sshd.<p>The way that I like to do this is to have a common &#x27;entry point&#x27; for all my cloud systems. Instead of whitelisting IPs on every VPS or cluster I build, I just add them to the ACL on my management server. All the other systems only allow SSH connections in from the bastion server. In practice, it works like this:<p>* Add IP to the whitelist file in my change control<p>* Run the Terraform script to update the DigitalOcean ACL<p>* Start an SSH agent locally and add the key for the bastion, as well as the key for the destination<p>* Connect to the destination server by using ProxyJump<p>So, connecting to a box would always route through my bastion system first, like this:<p><pre><code> ssh -J mgmt.mydomain.net cool-app-server.mydomain.net </code></pre> I&#x27;ve been doing this for a couple years, and it works great. I practically never have attempted login attempts on my systems. And, since I use an ssh agent to forward the keys through the bastion without ever actually storing them, a compromise of that system doesn&#x27;t really give the attacker anything other than access to port 22 on a bunch of systems that they wouldn&#x27;t know where to find. Only the most sophisticated attack (<a href="https:&#x2F;&#x2F;xkcd.com&#x2F;538&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;538&#x2F;</a>) would lead to a real compromise.
评论 #24369699 未加载
manexploitsmanalmost 5 years ago
I like this &quot;proactive&quot; solution :) Endlessh: an SSH Tarpit <a href="https:&#x2F;&#x2F;nullprogram.com&#x2F;blog&#x2F;2019&#x2F;03&#x2F;22&#x2F;" rel="nofollow">https:&#x2F;&#x2F;nullprogram.com&#x2F;blog&#x2F;2019&#x2F;03&#x2F;22&#x2F;</a>
CamJNalmost 5 years ago
6. Possible enhancements<p>Rate limiting the number of requests that can be made to the application<p>So this just moves the brute forcing target from ssh to a web app. A lot of work for no added security.
oehtXRwMkIsalmost 5 years ago
If I have public key authentication set up for ssh, should I even bother with fail2ban, firewalld-rest, port knocking, etc.? There&#x27;s no way anyone is brute forcing my ed25519 key, so what&#x27;s the point? Sure security should be layered and all that but it seems like public key auth is so strong by itself anything on top seems unnecessary.
评论 #24367682 未加载
评论 #24367851 未加载
评论 #24367212 未加载
评论 #24367640 未加载
评论 #24367970 未加载
gregodalmost 5 years ago
If you do not need the more granular firewall configuration options there is also classic port knocking (<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Port_knocking" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Port_knocking</a>) where the daemon sits behind the firewall so all ports can be closed by default.
peterwwillisalmost 5 years ago
A dynamic IP filtering list is still reactive because you haven&#x27;t actually secured the box or its services. You&#x27;ve just made it slightly inconvenient to brute force. You might as well use port knocking, because even with a fancy schmancy authentication system (and the attack surface of a custom web app...) I can MITM your active connections just fine either way, or spoof your whitelisted IP.<p>I know everybody likes Fail2ban, but these two iptables rules (or something just like them) actually work better and don&#x27;t fill up your logs:<p><pre><code> iptables -t mangle -A PREROUTING -p tcp --dport ssh -m conntrack --ctstate NEW -m recent --set iptables -t mangle -A PREROUTING -p tcp --dport ssh -m conntrack --ctstate NEW -m recent --update --seconds 60 --hitcount 4 -j DROP </code></pre> To actually protect the network layer, use some kind of VPN with MFA.
geocrasheralmost 5 years ago
This is interesting in that it combines the concept of port knocking with a REST interface, which I&#x27;m assuming is up to the user to create a front end for.<p>Unfotunately it also relies on Kubernetes which means that using it for a single system isn&#x27;t practical. At least, not for <i>this</i> server owner.<p>My own approach is simply security by obscurity (a non standard port) with APF&#x2F;BFD doing the needful for locking bots out if they figure out the port. I&#x27;ve had to change ports only once in 6 years, so it&#x27;s working to keep bots out rather nicely.<p>And really that&#x27;s all these things are- a way to keep bots out. A determined attacker will figure this stuff out anyway.
ed25519FUUUalmost 5 years ago
Secure SSH and you won&#x27;t have to worry about rogue login attempts, which happen to everyone. If it really bothers you then move it to another port where it will happen less.<p>But install a new firewall management system? Sounds like it will definitely introduce more risks than the problems it solves, which for the SSH example isn&#x27;t really a problem at all.
ff7c11almost 5 years ago
Have you tried knockd <a href="https:&#x2F;&#x2F;linux.die.net&#x2F;man&#x2F;1&#x2F;knockd" rel="nofollow">https:&#x2F;&#x2F;linux.die.net&#x2F;man&#x2F;1&#x2F;knockd</a> ? You send a special sequence of &quot;knocks&quot; to the server (packets to different ports) and it executes a command such as allowing your IP for a time period. No JWTs.
评论 #24373998 未加载
评论 #24368004 未加载
jlgaddisalmost 5 years ago
If you&#x27;re gonna go through all of this work -- including creating and maintaining private keys -- why not just restrict the SSH server to only permit key-based authentication (optionally, signed by your CA)?<p>If having 22&#x2F;TCP open to the world is an issue, then set up Wireguard on the host and only allow SSH connections that are coming in over the Wireguard interface.<p>Got a bunch of machines to deal with? Set up a jumpbox or two running OpenBSD, lock it down, give your users access to it via SSH (optionally, over a Wireguard connection) and then only allow SSH access to all of those other hosts from the jumpbox(es).<p>Then there&#x27;s the fact that I have a <i>whole lot more</i> trust in the security of OpenSSH than I do some random web application!<p>To me, this just seems kinda pointless -- there&#x27;s a bunch of other, better (IMO) ways to deal with this -- but I guess if it fits your needs ...
评论 #24370252 未加载
deathanatosalmost 5 years ago
&gt; <i>you can go to jwt.io and generate a valid JWT using RS256 algorithm (the payload doesn&#x27;t matter). You will be using that JWT to make calls to the REST application, so keep the JWT safe.</i><p>The JWT you got after you plugged the private key into a random website is going to protect access to your machine?
koolbaalmost 5 years ago
Adding a JWT authenticated API layer to something is not a first choice for adding additional security.<p>If you want something like this look into platform level firewalls (ex: AWS security groups) or run spiped in front of your SSH server. I’d trust that a hell of a lot more than a REST API.
deeblering4almost 5 years ago
Requiring ssh keys, disabling password auth, and using ssh bastion hosts is my preferred approach.
评论 #24368812 未加载
abpavelalmost 5 years ago
This looks like reincarnation of &quot;Lock &amp; Key&quot; feature of Cisco routers available since the late 90s. There were two major issues that led to abandonment and hindered adoption. The first is that it&#x27;s an extra step. Extra steps for installation, for complexity, for single point of failure, for availability of key services. The second is that instead of thwarting attackers, you&#x27;re thwarting yourself, every single time. It breaks so many usecases, for example if you have a new machine, or if you want to access through a jump host, or from ssh client on phone, etc.
john-shafferalmost 5 years ago
On EC2, I&#x27;ve had a great experience using AWS Systems Manager [1]. I don&#x27;t need any ports open, and it works great with normal shell tools and emacs given a .ssh&#x2F;config like this:<p>host i-* mi-*<p>ProxyCommand sh -c &quot;aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters &#x27;portNumber=%p&#x27;&quot;<p>[1] <a href="https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;systems-manager&#x2F;latest&#x2F;userguide&#x2F;what-is-systems-manager.html" rel="nofollow">https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;systems-manager&#x2F;latest&#x2F;userguide...</a>
MrStonedOnealmost 5 years ago
Documentation and idea framing is too snowflaked.<p>This a JWT based port knocking over https framework that would be useful when used in a much broader sense.<p>Framing it as proactive fail2ban is technically correct, it also masks the other and more powerful use-cases.<p>I could see this in use as a vpn bypass for a prosumer production system, where normal operational commands go over a secured vpn but in a pinch, you can disable that restriction for direct control during a partial failure.
swinglockalmost 5 years ago
A proactive way of increasing your attack surface no doubt.
评论 #24369208 未加载
netsectodayalmost 5 years ago
Please don&#x27;t use this software. From a security perspective this is horrible.<p>Option A) Expose all firewall rules via some hacky web-based API.<p>Option B) <a href="https:&#x2F;&#x2F;nvlpubs.nist.gov&#x2F;nistpubs&#x2F;ir&#x2F;2015&#x2F;NIST.IR.7966.pdf" rel="nofollow">https:&#x2F;&#x2F;nvlpubs.nist.gov&#x2F;nistpubs&#x2F;ir&#x2F;2015&#x2F;NIST.IR.7966.pdf</a>
solaticalmost 5 years ago
If you&#x27;re going to take this approach, a bigger question is why bother running the SSH jumpbox 24&#x2F;7 in the first place? Shut down the SSH jumpbox when you don&#x27;t need it (thus achieving SSH isolation) and start it up with your public IP in user-data to enable access to you and only you when you do need it.
Jnralmost 5 years ago
This sounds like a complex port knocking setup with bigger overhead. If you want better security and UDP is not a problem, consider use of Wireguard VPN. It is passive and silent, random attackers won’t even know it is there.
Tepixalmost 5 years ago
Running SSH on a non-standard port gets rid of the brute force login attempts, too.
评论 #24367779 未加载
nine_kalmost 5 years ago
(1) The auth interface is per IP address, as visible by the listening server. (2) The word &quot;NAT&quot; is found 0 times in the text. (3) There is no point 3 from the practical standpoint, please move along :(
gitgudalmost 5 years ago
Much simpler to stick with SSH and an IP Address whitelist...<p>Then you can&#x27;t even get login attempts, unless they&#x27;re from the same IP... am I missing something?
cpercivaalmost 5 years ago
I still think that running ssh over spiped is more secure. Every byte being passed to sshd is cryptographically verified (and encrypted).
wruzaalmost 5 years ago
Can anyone explain what&#x27;s wrong with &quot;pubkey only, ignore attempts&quot; method?
johnisgoodalmost 5 years ago
I just whitelist IPs. You can do this easily using iptables or sshd config.
hitpointdrewalmost 5 years ago
Why is SSH open to the public internet at all, ever? Use WireGuard as VPN tunnel to your servers network, then SSH via internal IP.
评论 #24369218 未加载
评论 #24368724 未加载
评论 #24370099 未加载
johnghanksalmost 5 years ago
Wow - why didn&#x27;t I think of just setting up a firewall instead of running fail2ban. Great idea.
评论 #24366978 未加载