Ssh – Specify SSH Port for Git

gitssh

I use a non-standard ssh port (1234) for most of the servers I connect to. So in my ssh config file I have:

Port 1234

But github.com uses port 22. When I try to connect to github it obviously tries to use port 1234. Right now I have to edit my ssh config to get things to work.

Here is a snippet from my git config:

[remote "origin"]
        url = git@github.com:asdf/asdf.git

Best Answer

Just have a look at how to set up your ~/.ssh/config file correctly (man 5 ssh_config). You can specify different settings for different hosts easily. To solve your problem you would set

Host github.com
Port 22
Host *
Port 1234

Do have a look at the ssh_config manual page, it explains everything you need to know on the first few pages.