You are not logged in.
Hi fellows. I am trying to forward a port from my pc to another one in the network using ssh.
With only learning purposes, I'm trying to connect to the mpd of the server, via a tunneled ssh connection. First of all, the ssh shell works perfectly.
Now, to make the port tunnel I execute:
$ ssh -v -NL 1919:myserver:6600 root@myserverWhere 1919 is an arbitrary port, 6600 is the mpd port in the server, and myserver is of course a IP in /etc/hosts. When I execute that, it seems it will work until I try this command:
$ ncmpcpp -h localhost -p 1919But it says: "Connection closed by the server'. At the same time, the verbose output of ssh shows:
channel 1: open failed: administratively prohibited: open failedTCPforwarding is enabled in the ssh server. What am I doing wrong? Thanks in advance.
Last edited by sironitomas (2011-03-12 19:42:34)
Offline
Can you try a higher port (e.g. 13000) instead of 1919?
Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd
Offline
I don't think you're doing it correctly.
$ ssh server -L 1919/localhost/6600Did you:
configure your mpd client to use localhost:1919 as its sever?
setup port forwarding in /etc/ssh/sshd_conf
Post your /etc/hosts.allow too.
Last edited by graysky (2011-03-12 18:13:41)
Offline
... and the /etc/hosts.allow in the receivng system allows the connection. Correct?
And, of course, if there are any firewalls in the receiving server it should also allow the connection.
Hope this helps.
R.
@graysky, you are too fast for me ![]()
Last edited by ralvez (2011-03-12 18:14:22)
Offline
Thanks for the answers. I was doing it wrong, although I still don't understand why.
graysky's answer did the trick!
It works with any of these:
$ ssh -L 1919/localhost/6600 root@myserver$ ssh myserver -L 1919/localhost/6600 -l rootThose are both the same, right? The explanation in man is a little bit confusing for me...
According to man:
[bind_address:]port:host:hostportSpecifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side...
So in my original post, I gave it port=1919, host=myserver and hostport=6600. Why didn't it work that way?
Last edited by sironitomas (2011-03-12 20:40:58)
Offline
A better question is what is it you mean by SOLVED? You just forwarded port 1919 on local machine to port 6600 on the same computer...
What hapens if you do
telnet 1919 localhostPerhaps, an example is in order. Suppose I have a firewall, which blocks outgoing traffic to port 993 (secure imap). This means, that I can not use fetchmail to get emails from imap.gmail.com. However, I can circumvent this by doing:
ssh -vxNL 13001:imap.gmail.com:993 user@some.server.eduand point fetchmail to localhost:13001. Then, the request to local port 13001 will be forwarded to some.server.edu, and from there to imap.gmail.com:993.
Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd
Offline
A better question is what is it you mean by SOLVED? You just forwarded port 1919 on local machine to port 6600 on the same computer...
No, I think you misunderstood something. I just forwarded port 1919 in my local machine to port 6600 in the server. I wasn't able get it working and that's why I posted here in the first place. Thanks to graysky's answer I finally could make it work.
What it is not "solved" is my understanding on the syntax of the -L option.
PS: I also don't know exactly why is localhost given instead of myserver.
Last edited by sironitomas (2011-03-12 20:39:28)
Offline
PS: I also don't know exactly why is localhost given instead of myserver.
That's kinda my point, because "-L x:host:y some.server" means "take traffic from any local program to local port x and forward it to host's port y through some.server". I did what you were doing in the OP (ntc and haf1 are two machines):
[ntc] ~> ssh -xvNL 13001:localhost:5001 haf1
...
[ntc] ~> ssh -p 13001 localhost
ssh_exchange_identification: Connection closed by remote hostbecause there is no sshd on port 5001, and ssh output on [ntc]
debug1: Local connections to LOCALHOST:13001 forwarded to remote address localhost:5001
debug1: Local forwarding listening on 127.0.0.1 port 13001.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on ::1 port 13001.
debug1: channel 1: new [port listener]
debug1: Entering interactive session.
>>>debug1: Connection to port 13001 forwarding to localhost port 5001 requested.
debug1: channel 2: new [direct-tcpip]
channel 2: open failed: connect failed: Connection refused
debug1: channel 2: free: direct-tcpip: listening port 13001 for localhost port 5001, connect from 127.0.0.1 port 33937, nchannels 3Please note the first and ">>>" lines? What am I missing?
Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd
Offline
Offline