1

I have a hosting plan from the folks at HostGator. They allow SSH connections on port 2222. I'm using "Git Bash" on Windows to connect to HostGator via SSH. Works fine with ssh -p 2222 <hostX>. Next step, I try to set up a git remote repository in my public_html folder like so:

mkdir test
cd test
git init

and no problems thus far. I can add it to my local repository via git remote add <repoLocalName> <hostX>:/public_html/test. Next thing I try is to fetch from the remote repository trough git fetch <repoLocalName> - this comes back with an error: "ssh: connect to host port 22: Bad file number; fatal: Could not read from remote repository."

So I'm thinking to set up a config file. I create one here: ~/.ssh/config and it has the following lines that are either not taken into account or give out errors:

Host <hostAddress>
Port 2222
PreferredAuthentications publickey,password

The host is not recognized, port not recognized either, and the PreferredAuthentications parameter gives an error - so there's definitely something I'm not doing right with the whole config file aspect of the problem.

What I'm trying to accomplish with this whole procedure is a deployment on a live test server of a website I'm working on - so it's kind of a learning curve - but the above problems have stopped me in my tracks.

1
  • Wasn't sure where to post. Should i bounce this to stackoverflow? Commented Jul 27, 2015 at 15:45

1 Answer 1

1

Specify an ssh: URL which allows you to set the port.

git remote add <repoLocalName> ssh://<hostX>:2222/public_html/test
3
  • Two points: 1) There are no issues with adding a remote repository. 2) i tried to do that with git fetch but it doesn't really work - the error i get is invalid refspec 'ssh://...'. Commented Jul 27, 2015 at 16:13
  • 1
    If there are no issues with adding the remote repository, then I don't understand your question. The base of the question, as I am reading it, is "I cannot access my remote repository". If you cannot git fetch, then how is it your remote repository has no issues?
    – Dan Lowe
    Commented Jul 27, 2015 at 16:15
  • 1
    So apparently, i should have added the remote repository the way you specified, before anything else. So your solution works, but the question of why the config file is not read or the errors associated with it, remains. Now the problem deepens. Apparently, when i fetch, the repository that's right there, git says is not a repo, but this is a different question. Commented Jul 27, 2015 at 16:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .