Technology

Corkscrew: SSH over HTTP Proxy

I found myself behind a firewall that didn't allow SSH to the outside world.  They did allow an HTTP proxy though.  So I thought:  Let's make sure we can get out!  After all, I needed to download some of my code from Github, make changes, and then upload again. Here's how I did it.

1.  Install Corkscrew

wget http://www.agroman.net/corkscrew/corkscrew-2.0.tar.gz
tar zxvf corkscrew-2.0.tar.gz 
cd corkscrew-2.0 
./configure 
make
make install
which corkscrew
 

2.  SSH Config

Now let's make github work.  We edit ~/.ssh/config
Host github
  Hostname github.com
  User git
  ProxyCommand corkscrew myproxy.com 80 %h %p
Now we can test by running: ssh github This gives us the familiar response:
PTY allocation request failed on channel 0
Hi vallard! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
I won't worry about the channel 0 failure.

3. Git Config

Inside our git repository, we can update .git/config to point to the alias of github.
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    # this is the way it would work natively without proxy. 
    #url = ssh://git@github.com/vallard/Ansible-Ubuntu-OpenStack.git
    
    # instead we use the alias in our ssh config to push it up. 
    url = ssh://github/vallard/Ansible-Ubuntu-OpenStack.git
Now we can do git push without any issues!