1

very short and basic question, i'm having trouble in a network's homework i'm having. This is the point i'm asked to implement:

  • Configure SSH remote port forwarding in order to redirect the port 83 of pc1 to the port 8000 of s1.

To do it, i used a simple

s1:~# ssh -o StrictHostKeyChecking=no -NR 83:127.0.0.1:8000 ssh_user@10.0.1.2 &

Where 10.0.1.2 is the ip of pc1, however every time i receive as return the warning:

Warning: Remote Port Forwarding failed for listen port 83

I have nothing running that's already using the 83, also if I try to locally (from pc1) try to listen on port 83 I can easly do it.

Note: i receive this error from all the privileged ports i try to bind.

1
  • We ended up solving it with another tool with sudo to forward the privileged port. With ssh, forward a non-privileged port like 1443, then with socat do sudo socat TCP-LISTEN:443,fork TCP:127.0.0.1:1443
    – Luc
    Jul 6, 2021 at 12:43

2 Answers 2

1

You either need to be root to bind ports below 1024 or have the CAP_NET_BIND_SERVICE capability. In order to obtain it run:

 sudo -E -- setpriv --inh-caps +net_bind_service --ambient-caps +net_bind_service --reuid $USERNAME /bin/bash

This runs as root the setpriv utility, which switches back to your uid, but adds the CAP_NET_BIND_SERVICE capability.

0

You need to be root on pc1 aka 10.0.1.2 in order to redirect ports less that 1024, rather than ssh_user.

Since you can bind port 83 if you are logged onto pc1 (presumably as root), it might be easier to start from pc1 and ssh to s1. Use '-L' to bind port 83 locally rather than '-R'.

1
  • The user on s1 is root, on pc i tried to move ssh_user as a root user with :"usermod -aG sudo ssh_user" but nothing changed. Yeah, it would be much easier to use a local port forw. but that's not what i'm requested to implement :c
    – Ozozuz
    Nov 26, 2019 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.