News for hackers. Stuff that matters.
Re:A customer stuck due to a hurricane who needed SSH by fiddlerwoaroof on Thursday September 21, 2023 @08:59PM (#37606565)
An advantage of “iptables magic” is that the service doesn’t ever have to run as root: I’ve done this before to great success to have a web server be accessible on standard ports even though it was running as an unprivileged user.
Re:A customer stuck due to a hurricane who needed SSH by f33d5173 on Thursday September 21, 2023 @09:45PM (#37606907)
There's a capabilities thing you can do to add the permission to a process without changing users. You can also have it bind to the port as root then drop permissions afterwards.
Re:A customer stuck due to a hurricane who needed SSH by fiddlerwoaroof on Thursday September 21, 2023 @10:41PM (#37607241)
Yeah, but requiring the process to start as root adds a window of vulnerability
Re:A customer stuck due to a hurricane who needed SSH by superb_dev on Friday September 22, 2023 @01:36AM (#37608283)
Systemd can setup the privileges before starting the process
Re:A customer stuck due to a hurricane who needed SSH by greyface- on Friday September 22, 2023 @09:35AM (#37611878)
Run this as root once:

  setcap 'cap_net_bind_service=+ep' /path/to/executable
Now, the process doesn't need to start as root and drop privs.
Re:A customer stuck due to a hurricane who needed SSH by dijit on Friday September 22, 2023 @03:53AM (#37609181)
this is actually dangerous advice.

The reason privileged ports require root is so that they cannot be easily intercepted by userland processes.

The entire reason for the root requirement is this; it's expected that after your port assignment you drop your privileges to a lesser user. But requiring root to bind is a feature, not a bug.

If you do not have this then intentionally crashing the process for a user and rebinding the port as a standard user (even `nobody`) is possible.

This means if you break into someones mail server and run as the mail user, you would be able to bind ssh ports (if they are not privileged ports <1024).

Of course your mail server should be running as the `mail` user or some equivelent, because only the binding of the ports should be done on startup as root and then it should drop into the mail user.

Re:A customer stuck due to a hurricane who needed SSH by fiddlerwoaroof on Friday September 22, 2023 @04:08AM (#37609285)
Only if you can kill the ssh server that's already listening on the port.
Re:A customer stuck due to a hurricane who needed SSH by dijit on Friday September 22, 2023 @04:21AM (#37609382)
Yes, but you can do so as a regular user in some cases.

Security is an onion.