Creating the Secure Tunnel

Our EC2 instance is all set up, but it’s not a proxy yet. We can turn it into a proxy by running the following command with the amazonaws.com address replaced by the server’s DNS name:

 
$ ​ssh -R *:5900:localhost:22 -i ~/.ssh/amazon.pem \
 
> ubuntu@ec2-0-0-0-0.compute-1.amazonaws.com -N

The -R option tells the ssh command to create a reverse tunnel (that is, the traffic received by the proxy will be forwarded to the machine that ran the ssh command). The *:5900:localhost:22 argument, which is passed to the -R flag, instructs the command to map port 5900 on the proxy to port 22 on localhost (that is, the computer from which we ran the ssh command). We’ve chosen to use 5900 because it is a common port for tools ...

Get Remote Pairing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.