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#"

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

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
  • Daniel: Thanks Tim for coming over! Icant $get that day to me that was like a boost to my skills I was thnki [...]
  • Iyinoluwa Balogun: i think curiousity comes first. those who have left footprints in the sands of time started by quest [...]
  • Kizito S.M.: What I gather is that this G-Buzz is something like a blend between Facebook Updates and Twitter fol [...]
  • concept37: They are trying to out-facebook facebook and out-twitter twitter, Folks who want to do these things [...]
  • ray: Funny u took it from the LBS angle, which makes better sense. But from the social networking perspec [...]

Subscribe to this blog via email

Enter your email address: