Programming Unix

27 Aug 2015

Change port git is using for ssh

Preston Garrison 0 Comments

Recently I changed the port on our git server to a more secure ssh port.   It is highly recommended you don’t use port 22 for SSHd.   You will most likely notice tons of brute force attacks to your server with in minutes of putting it online, if you use the standard port.  Unfortunately this puts extra load on server, and it really can waste a good amount of bandwidth.   Once you switch the port on your server you will probably notice you can no longer connect via git.  The solution to fixing this is simple..

 

If you edit your .git/config file you will notice urls in the following format:

url = git@git.yourcompany.com:appdir/appname.git

 

You need to convert it to the ssh format, and remove .git from the end, using the following format:

url = ssh://git@git.yourcompany.com:10022/appdir/appname

 

Its that simple, and you should now be able to access your git repository once again.

 

Preston Garrison