How to setup .ssh/config for git on non-standard port
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.
linux ssh git openssh
add a comment |
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.
linux ssh git openssh
add a comment |
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.
linux ssh git openssh
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.
linux ssh git openssh
linux ssh git openssh
asked Dec 20 '18 at 13:40
ZioByteZioByte
200111
200111
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1386282%2fhow-to-setup-ssh-config-for-git-on-non-standard-port%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
add a comment |
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
add a comment |
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
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
answered Dec 20 '18 at 16:32
eggoeggo
1,301612
1,301612
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1386282%2fhow-to-setup-ssh-config-for-git-on-non-standard-port%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown