Port 2222 Blocked Workaround

Instructions for accessing Port 2222 using and SSH tunnel on your Pantheon Drupal or WordPress site.


In order to push and pull code to your Pantheon site, you'll need access to port 2222. If for some reason this port isn't open to you, either because of a corporate firewall or router configuration, you'll get an error like the following:

SSH: connect to host codeserver.dev.<site UUID>.drush.in port 2222: No route to host
Fatal: Could not read from remote repository.

Prerequisites

You can use an SSH tunnel to get around this barrier. To set this up, you'll need SSH access to an another server somewhere outside of your network that can access port 2222 and reach Pantheon's Git servers. Once you get the command to open a tunnel working, keep it handy because you'll need to open the tunnel before performing any remote Git operations.

Set up the Tunnel

Open a terminal window and initiate the SSH tunnel:

ssh -L<local port #>:<pantheon server>:<pantheon port> user@other-server.com

The following example includes Pantheon credentials (site UUID omitted). You can use the port numbers from this example, at a minimum, you'll need to leave port 2222 in place.

ssh -L3333:codeserver.dev.<site UUID>.drush.in:2222 user@other-server.com

You should now be logged in to the other server, but simultaneously you've just set up your local port 3333 as a tunnel to your Pantheon Git repo.

Clone the Repo

Open a second terminal window and clone the repository:

git clone <Pantheon repository URL>@localhost:3333/~/repository.git

Here's an example with Pantheon credentials (site UUID omitted):

git clone ssh://codeserver.dev.<site UUID>:3333/~/repository.git

You now have a fully cloned repo that you can push and pull from.

Add a Remote (Optional)

If you use GitHub or Bitbucket in parallel, run something like the following (as with any remote Git operations, the tunnel must be open already):

git remote add pantheon ssh://codeserver.dev.<site UUID>@localhost:3333/~/repository.git

Additional Information

If any remote Git commands stop working, check the original terminal window to see if the tunnel has collapsed, and reopen if necessary.

For more information, see the following post:
https://randyfay.com/content/git-over-ssh-tunnel-through-firewall-or-vpn

Props to Thomas MacLean for contributing to this documentation!