Using Git over non-standard SSH ports

In: Programming|Web Development

14 Sep 2009

I’ve configured some deployment servers to use SSH over non-standard SSH ports and that can really be a problem when you want to use that with git. No matter what you do, git would always attempt to connect through the standard SSH port 22.

There was really no point in scratching my head and trying to pull my hair out in order to fix this. So I googled a solution. This post gave me a hint but wasn’t helpful enough so I decided to write a blog post on how to go about solving this.

You’ll have to configure your repository in your .ssh/config file. Here’s an example. Simply substitute the #*# placeholders for the actual values

Host #hostname#
  User #username#
  Hostname #hostname#
  Port #non-standard port#

And if you prefer to use private keys to login:

Host #hostname#
  User #username#
  Hostname #hostname#
  Port #non-standard port#
  PreferredAuthentications publickey
  IdentityFile "#path_to_private_key#"

4 Responses to Using Git over non-standard SSH ports

Avatar

Florian Vallen

October 9th, 2009 at 4:14 pm

Thank you so much. You safed my time

Avatar

Josh Fraser

November 22nd, 2009 at 11:13 pm

Very helpful. Thanks for posting this.

Avatar

Tim

November 23rd, 2009 at 3:17 pm

@josh and @florian, thanks for your comments and welcome to my blog.

Avatar

exn

December 17th, 2009 at 12:24 pm

Maybe is another solutions ?
What you can suggest me if I have more than one repository via multiple logins and ports to the server ?

Comment Form

About this blog

Tim Akinbo's Weblog is the personal weblog of Tim Akinbo. Here he discusses issues relating to technology. Special interests include the web, mobile technology and location based services.

Photostream

    Panel Session on Realizing Nigeria's Internet PotentialDelegates during Justin's Keynote PresentationBarCamp Attendees 1main hallmain hall 2main hall 3
  • Budzeg: I remember the days of mobile too... When we were building wapitis like it was going out of fashion. [...]
  • damiet: Tim i think the society has in some way showed us that technology, engineering, etc are male stuff. [...]
  • Tim: @Trae, my memory fails me. You\'re right I did start blogging in 2004 :) Hmm... so many years gone b [...]
  • trae_z: I started blogging late 2008. For one reason or the other, I lost the first two incarnations of m [...]
  • Tim: That would depend on what application is being built but I did read up uniPaaS and it's worth t [...]

Subscribe to this blog via email

Enter your email address: