1

I know something similar has been asked multiple times, but I wasn't able to find the right solution for my case.

I have a custom git repository accessible via ssh on a non-standard port; URL is something like:

git clone ssh://myname@my.repo.host:12345/path/to/repo/project.git

private key for that repo is in ~/.ssh/myname.prv.

I am trying to get access the repo without passwords, but I'm failing.

My current ~/.ssh/config has a stanza:

Host git
    HostName my.repo.host
    Port 12345
    User myname
    IdentityFile ~/.ssh/myname.prv

... but git still asks for a PW.

What am I missing?

Note: both server and client are fairly recent Linux machines and I'm working at the command line, if it matters.

3

I believe you are misunderstanding the use of the ~/.ssh/config file. You have:

Host git
    HostName my.repo.host
    ...

However, the first line Host git defines the name (alias) (i.e. git) of the host to connect to and that which you specify on the command line to either ssh or git. That is, you could now ssh to your git remote server via

ssh git

... and you can clone the git repo using your 'custom' hostname using:

git clone ssh://git/path/to/repo/project.git

Note that your remote will now list origin as exactly that address, which is dependent upon your ssh config file.

Alternatively, if you wish to retain the my.repo.host in the address of your git remote, change your ~/.ssh/config to read:

Host my.repo.host
    #HostName my.repo.host
    Port 12345
    User myname
    IdentityFile ~/.ssh/myname.prv

( NOTE: The HostName directive is redundant in this case, so I left it commented out. )

With that, you could simplify your remote and clone using:

git clone ssh://my.repo.host/path/to/repo/project.git
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.