So, this is not my “typical” IDM post but I wanted to save this for my own future reference.
Working from Mac OS X desktop and connecting to an EC2 (Redhat) instance over SSH. I am installing and configuring Symfony which requires (strongly desires) that you connect to the config.php script from localhost (127.0.0.1).
1.) Modify PHP script to comment out the localhost checks (boring)
2.) Create a SSH tunnel from Mac terminal to the web port on the EC2 instance
The first option is pretty obvious and requires basic skills. I am not sure what the ripple effects are with this so I’d prefer not to go this route.
The second option earns more “skillz” points and doesn’t require you to modify the config.php file, from Symfony. Note: Originally, I was using port 81 as the local port. I changed the local port to 1337 vs 81. Chris (see comments) made an excellent point that you don’t need to use sudo if your local port is higher than 1024.
1. Open Terminal Window from OS X desktop
2. Type: ssh -i mykey.pem -L 1337:am.acme.com:80 am.acme.com
So what did we do here:
ssh -i mykey.pem: connect to remote server using ssh with the key that you use to connect to Amazon instance (you do use keys right??)
-L 1337:am.acme.com:80: Local port (on OS X) will be 1337 and map that port to 80 on the EC2 instance URL am.acme.com
am.acme.com: this is the remote (EC2 instance) hostname
3. The first time you connect to this server you will be asked to add this host to your known hosts file (say yes)
4. Open a web browser (from OS X) and enter “127.0.0.1:1337/Symfony/web/config.php” to connect to the Symfony config on the EC2 instance
As long as you keep the SSH connection open then you can use the tunnel. To close the tunnel, just exit from the SSH session.