0

I have a remote machine running a server which I'd like access to locally. However, I can only SSH into the machine, not use any other ports.

I booted up an Amazon EC2 instances and opened all its ports. The plan is to set up a remote tunnel from the machine to the ec2 instance.

On the remote machine, the server is working:

$ links http://localhost:5555/foobs

This accesses the foobs page correctly. On EC2, I can access port 5555 if a server is hosted there:

$ echo really > index.html
$ python -m SimpleHTTPServer 5555
Serving HTTP on 0.0.0.0 port 5555 ...

Then, from my local browser: http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com:5555/ gives me the "really" page.

However, if I do port forwarding, from the machine:

$ ssh -R 5555:ec2-xx-xx-xx-xx.compute-1.amazonaws.com:5555 -i keys/key.pem [email protected]

Then pointing my browser at http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com:5555/ does not get me the page. The app that uses it gives ERR_CONNECTION_REFUSED. However, the port is being used. If from the ssh shell that's doing the forwarding I try to run the server on the same port:

$ python -m SimpleHTTPServer 5555
...
socket.error: [Errno 98] Address already in use

What gives? I am not the biggest networking wizard, as might be evident.

3
  • So why does the EC2 instance need to be involved?
    – EEAA
    Sep 15, 2014 at 19:56
  • @EEAA: I can only connect to the remote machine via the SSH port. I can't open any ports on the remote machine. But I need to connect to a server running on the remote machine. I also can't SSH from the remote machine to my local machine.
    – Claudiu
    Sep 15, 2014 at 19:59
  • You're making this far too complicated. See my below answer.
    – EEAA
    Sep 15, 2014 at 20:00

2 Answers 2

3

From your local machine:

$ ssh -L5555:localhost:5555 [email protected]

Then you'll have access to port 5555 on the remote machine from your local system. Just point your browser to http://localhost:5555/

1
  • Worked like a charm, thanks. I should have seen it.
    – Claudiu
    Sep 15, 2014 at 21:56
0

It looks like you need to enable Port Forwarding in Amazon Elastic Load Balancer for the port 5555. Do you use ELB in front of your instance?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .