Daily Archives: November 9, 2013

Using SSH Tunnel to make my Laptop Appear to have a Real Internet Address

Sometimes I need to have a development version of a Sakai running with a real IP address on the real Internet. For example to run the IMS Learning Tools Interoperability certification I need to have my Sakai accept web service callbacks form the IMS server.

One way to do it is to run an Amazon EC2 instance but this is a pain. I need to login a bunch of times to get all the windows I want and I cannot use any desktop apps. And I need a big EC2 instance and need to install a bunch of stuff – yada yada – and I have all that stuff already on my desktop.

So here is the procedure.

First make the smallest possible Amazon EC2 Instance. Make sure to open port 8080 on your instance. Log in to the instance and edit the sshd configuration file:

sudo vi /etc/ssh/sshd_config

Add or uncomment a line that says this:

GatewayPorts yes

Then restart sshd

sudo /etc/init.d/ssh restart

Then log out of the server and set up your SSH tunnel:

ssh -i .ssh/zzz.pem -R 8080:localhost:8080 ubuntu@ec2-23-22-200-200.compute-1.amazonaws.com

You can double check that your server is accepting connections from the outside world:

netstat -ntl

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN

In Sakai, you add the following to your sakai.properties:

serverUrl=http://ec2-23-22-200-200.compute-1.amazonaws.com:8080

Once your Sakai is up you should be able to navigate to

http://ec2-23-22-200-200.compute-1.amazonaws.com:8080/portal

And viola – everything is running on your laptop but the server is on the internet with a real address.

Update: What you need to do for DigitalOcean

Blog Post: https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-tunneling-on-a-vps

Sakai Setting:

serverUrl=http://do1.dr-chuck.com:8080

Code to restart SSHD:

service ssh restart

SSH Call:

ssh root@do1.dr-chuck.com -R 8080:localhost:8080