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?
Asked
Active
Viewed 1.2k times
2 Answers
6
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
poolie
- 9,161
- 4
- 38
- 62
-
Thanks, but when I try to do that via sudo, I get Permission denied (publickey). – mrSuperEvening Oct 18 '13 at 22:43
-
Maybe you need to specify the identity file. Try also using `ssh -v`. – poolie Oct 18 '13 at 22:46
-
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... – mrSuperEvening Oct 18 '13 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. – poolie Oct 19 '13 at 06:55
5
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
Oli
- 289,791
- 117
- 680
- 835