git remote add with other SSH port

In Git, how can I add a remote origin server when my host uses a different SSH port?

git remote add origin ssh://user@host/srv/git/example

  • Specify private SSH-key to use when executing shell command with or without Ruby?
  • Jenkins - Unable to git clone from slave node. SSH keys
  • Does heroku use my ssh key to fetch builpacks?
  • setting up git server on centos 7 in google compute engine
  • git pull is failing with error: cannot fork() for git-upload-pack
  • GitHub collaborators cannot download private repo via NPM package
  • Should I use my personal email in my ssh public keys?
  • Capistrano and Git, Ruining my life. “Unable to resolve revision for on repository …”
  • 5 Solutions collect form web for “git remote add with other SSH port”

    You can just do this:

    git remote add origin ssh://user@host:1234/srv/git/example

    1234 is the ssh port being used

    You need to edit your ~/.ssh/config file. Add something like the following:

        Port 1234

    A quick google search shows a few different resources that explain it in more detail than me.

    For those of you editing the ./.git/config

    [remote "external"]                                                                                                                                                                                                                                                            
      url = ssh://                                                                                                                                                                                                               
      fetch = +refs/heads/*:refs/remotes/external/* 

    Best answer doesn’t work for me. I needed ssh:// from the beggining.

    # does not work
    git remote set-url origin
    # work
    git remote set-url origin ssh://

    Found this link, and although it was helpful my blog entry might help clarify it:

    Basically i think its much better to just edit your .git/config file and make the changes. Hopefully this will help someone else..

    Git Baby is a git and github fan, let's start git clone.