SSH port forwarding: “Privileged ports can only be forwarded by root” error

opensshport-forwardingsshsudo

I wanted to forward my local 8080 port to the 80 port of the server I want to log in via SSH, so I did:

ssh -L 80:127.0.0.1:8080 -N -f myserver

But I get the error:

Privileged ports can only be forwarded by root.

I can execute sudo commands when logged in that server, but how can I do it for the purposes of port forwarding? (Note: appending sudo at the beginning of this command doesn't help, because the port 80 is not the port I want to use in localhost, but the port I want to target.)

Best Answer

You probably want

ssh -L 8080:127.0.0.1:80 -N -f myserver

Local port comes first. (That's not my political stance!)

Related Question