Setup ssh over https access to git server

If you are unlucky working behind firewall trying to connect to github/bitbucket using ssh. Here is the ssh-via-https git server you should redirect to:

GitHub:

ssh.github.com on 443 instead of github.com on 22

https://help.github.com/articles/using-ssh-over-the-https-port

BitBucket:

altssh.bitbucket.org on 443 instead of bitbucket.org on 22

https://confluence.atlassian.com/display/BITBUCKET/Use+the+SSH+protocol+with+Bitbucket

Those entries are added in ~/.ssh/config, on Windows machine it can be either on your %HOMEDRIVE% \ %HOMEPATH%, or C:\Users\your.name\.ssh, run ssh -vT git@github.com or ssh -vT git@bitbucket.org to find out.

Before redirect:

λ ssh -vT git@bitbucket.org
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /c/Users/fmao.AGLC/.ssh/config
debug1: Applying options for bitbucket.org
debug1: Connecting to bitbucket.org [131.103.20.168] port 22.
debug1: Connection established.
debug1: identity file /c/Users/fmao.AGLC/.ssh/identity type -1
debug1: identity file /c/Users/fmao.AGLC/.ssh/id_rsa type 1
debug1: identity file /c/Users/fmao.AGLC/.ssh/id_dsa type -1
(hang here, if 22 port is blocked.)

After redirect:


λ ssh -vT git@bitbucket.org
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /c/Users/myusername/.ssh/config
debug1: Applying options for bitbucket.org
debug1: Connecting to altssh.bitbucket.org [131.103.20.174] port 443.
debug1: Connection established.
debug1: identity file /c/Users/myusername/.ssh/identity type -1
debug1: identity file /c/Users/myusername/.ssh/id_rsa type 1
debug1: identity file /c/Users/myusername/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
...
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
logged in as maodd.

Custom Git Server

In case you want to connect to your own git server which you have root access, edit the /etc/ssh/sshd_config to add an additional listening port other than 22.

Add a new line with content of ‘Port 443’ right under the line of ‘Port 22’ in /etc/ssh/sshd_config

Restart ssh server: sudo /etc/init.d/ssh restart

Try the same thing in your client machine.

ssh -p 443 yourgitserver.com to ensure 443 can go through your firewall.

Follow the similar hostname setup in .ssh/config file mentioned above.

ref: https://help.ubuntu.com/12.04/serverguide/openssh-server.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s