Search code examples
gitamazon-web-servicesgit-shell

Correct url for windows to access my own git server


So i've got my git server setup on AWS, it worked perfectly fine on my mac and ubuntu, but i got trouble connecting it using windows. Here is the steps and the error i got.

Steps:

1. generate keys using "ssh-keygen -t rsa -b 4096"
2. put the key on server using "echo 'sshkey' >> .ssh/authorized_keys"
3. init repo on windows, set remote to "git remote add origin [email protected]"
4. setup config file with the public ip:
    Host git-myserver
        HostName <publicIP>
        User git
        IdentityFile ~/.ssh/keyForGitServer
        RequestTTY no

5. git pull origin master

And it gives me the following errors:

fatal: '[email protected]' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Any suggestions would be appreciated.


Solution

  • In your question, you said you're using:

    [email protected]
    

    This isn't a valid repository specification; you need to tell git (a) what username to use, (b) what remote host to use, and (c) what repository on the remote host to use. The canonical format of an ssh repository specification is:

    <user>@<remotehost>:<path_to_repository>
    

    So if you are connecting as the git user to myserver.example.com and accessing the /repos/myrepo.git repository, you would use:

    git remote add origin [email protected]:/repos/myrepo.git
    

    For repositories that are relative to your remote home directory you can use relative paths:

    git remote add origin [email protected]:myrepo.git
    

    You can also specify an SSH remote as:

    ssh://<user>@<remotehost>/<repository>
    

    More information is in the documentation.