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

1st day of using Git

When I was trying to review my patch to Fluent NHibernate of supporting StoreProc, I realized that FN has moved to GitHub, Oh well, time to learn something newer. At the end of day, I found it’ s not easy as I expected, even I already have been working on Svn for 1+ year.

Here are some terrible experience in my 1st day.

Where is TortoiseGit? The command line tool of git is awful, how can I prompt it to my team? I was completely lost at Git Gui.

As the document said, after ‘git init’ I should be able to do a ‘git clone’ same as ‘svn checkout’, but I couldn’t find it in Git Gui.

Ok, switch to command line then, which I hate it so much, type in ‘git clone git://github.com/jagregory/fluent-nhibernate.git’, it’s starting download process… done, the code is not in the folder where I pop-up the git bash, it’s in default path! C: or I:, what ever you got when you open the windows command window, next time I will pay more attention to the place when I pop-up git bash.

There must be a command to switch path, anyway, I got the code already, will figure this out later.