I want to port 127:0.0.1:80 to the other machine via SSH, how can I do that? I tried adding -R 8000:localhost:80, but it doesn't work. By the way, PHP is also installed on localhost, maybe that's why?
2 Answers
Only root can bind ports numbered under 1024.
The cleanest way is just to use local port 8000:
ssh -R 8000:localhost:8000 otherhost
Alternatively,
sudo ssh -R 8000:localhost:80 me@otherhost
(It's really better not to run this as root for the sake of security - just use another port.)
If you must use root, and you're using ssh private-key authentication, you may need to tell it which identity file to use. For example
sudo ssh -i ~/.ssh/id_dsa -R 8000:localhost:80 me@otherhost
-
Thanks, but when I try to do that via sudo, I get Permission denied (publickey). Oct 18, 2013 at 22:43
-
-
Thanks again, I logged it via sudo successfully, but it doesn't work... I just see 404 not found on 127.0.0.1:80... Oct 18, 2013 at 22:51
-
That's probably a different issue, perhaps connected to your server expecting to see a different virtual host name. Have a look in the server logs.– poolieOct 19, 2013 at 6:55
Judging from what you've just said in chat, this will let you access the server's port 80, from localhost:8080 (you'd need to run this as root to get it on localhost:80, which I don't advise if you can avoid it).
ssh -L 8080:localhost:80 host