9

I have ssh keys setup to work on a specified port (e.g. 12345) and issued the following git command to set the origin on a local repo.

git remote add origin myusername@mydomain.com:12345/path/to/public_html/files/

I am getting the following error message when i try to push to origin.

ssh: connect to host mydomain.com port 22: Connection refused
fatal: The remote end hung up unexpectedly

How do i set origin so it is using the proper port for ssh?

Jay
  • 6,206
  • 11
  • 48
  • 82
  • possible duplicate of [git remote add with other ssh port](http://stackoverflow.com/questions/3596260/git-remote-add-with-other-ssh-port) – Chris Johnsen Sep 08 '11 at 05:48

1 Answers1

12

To specify a custom port, you have to add the ssh:// prefix. Otherwise, git interprets your 12345 as part of the project's path. See URLs in the git-pull docs. So:

git remote add origin ssh://myusername@mydomain.com:12345/path/to/public_html/files/
Ryan Stewart
  • 126,015
  • 21
  • 180
  • 199