-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support SSH Git URLs for authenticated connections to private repositories #1851
Comments
This is actually supported, Cargo just doesn't prompt for a password (see #1306). You can use git credentials to store information (which Cargo reads). |
I've tried this before only a few weeks ago and it was not working as On Tuesday, July 28, 2015, Alex Crichton notifications@github.com wrote:
Sent from Gmail Mobile |
Ok, but if you run into any problems feel free to open an issue! It's a difficult code path to test and it's not exercised that much, so there may be a bug or two lurking. |
This is in fact an issue. I have my osxkeychain git credential helper setup, and my credentials are cached. All fresh terminals authenticate seamlessly to HTTPS GitHub URLs of private repositories. However, cargo continues to report
Please advise. Thanks in advance! EDIT: I have also tried a file store helper, which also does not work.
Do I need to setup credentials in some special way other than using a credential helper? |
Sounds like some investigation is warranted! |
As stated in the OP, SSH URLs in the form of This is a suggestion. Apparently one can use |
Specifically, it sounds like you had a submodule which used a URL of the form |
That's correct! Whether it is specified directly as the |
I actually thought this was working until I switched locations. I set up a project with a git Now that I'm on Linux, the same project ignores all .ssh config for git dependencies, though it does work when including the password, port number, and what I had for breakfast in the URL. |
Are you running through vagrant or something? In either case, is ssh-agent I've had no problems on OS X or Linux on vagrant with ssh-agent enabled in On Saturday, December 5, 2015, Si notifications@github.com wrote:
Sent from Gmail Mobile |
Physical machines, unfortunately in different countries. My best guess is that ssh-agent was running on the Mac without my realising it. As soon as I use ssh-agent here on Linux, it works as expected. I still need to be explicit about the port, but that may also have been the case on the Mac. The repo is just a personal one, so I was relying on ssh auth negotiation beforehand. |
@simon-nicholls you may also be running into #2078, right now Cargo doesn't take a look at |
Thanks. That clears things up for me. |
I would like to bump this issue. I am trying to connect to a remote, private ssh repository on Gitlab. I change the scp syntax I can clone the repository manually, as well as ssh into the server. |
@Binero change your URL to |
@jnicholls Gold. Worked nicely. |
I'm having a similar issue:
but cargo fails with:
Doing a Btw, I had to add an explicit port number because it's complaining about an invalid port number without it - maybe another bug? |
@mkollaro that actually looks like it's a different error perhaps? I believe |
On Mac OS X (Sierra) I had to create a
with the (private) rsa file pointed to, and then issue the command:
which (finally!) allowed an entry like:
to work perfectly. (Now I only have to cure the coding bugs.) I do not know how often I will have to repeat the This anomaly is apparently a feature of |
@Zteve I am seeing quite weird behavior when https://github.com/username/XXXX.git rejects to work, while switching prefix to |
@pronebird Yes, the scheme Have you tried it with |
@Zteve tried with |
I ended up writing down all the different ways to auth and the gotchas here: https://fahn.co/posts/cargo-auth-for-private-git-repos.html It got a bit long 😅 . Not sure if any of it is worth adding to the Cargo docs. |
It seems git changed the behavior of URL, all of upon solutions doesn't work anymore.
But changing the url argument of
Is it possible for the cargo to translate the URL to the correct one? |
I think reporting to Git developers that something changed would be better here. Can you, perhaps, bisect where GIt changed this behavior? |
The problem is git fetch supports the URL schema like I just think cargo should adapt the URL resolve mechanism of git, and solve the problem. |
Git supports |
I think I see the issue. You have |
Now we use an ssh connection to access the github repo. Be aware that you need a credentials helper for this to work as the repo is private and cargo will not prompt for a password. rust-lang/cargo#1851
Note to all other hipster it doesn't seem |
It seems very odd that the shell would affect something like that. Are there any other symptoms? |
There isn't much except the error output: ❯ cargo install --git ssh://git@github.com/xxx/xxxxx --branch main
Updating git repository `ssh://git@github.com/xxx/xxxxx`
error: failed to fetch into: /Users/onat.mercan/.cargo/git/db/xxxxx-db26b348fdd70ca7
Caused by:
failed to authenticate when downloading repository
* attempted ssh-agent authentication, but no usernames succeeded: `git`
if the git CLI succeeds then `net.git-fetch-with-cli` may help here
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
Caused by:
no authentication available
|
It seems like something is wrong with the The only thing fish could be doing is some magic on that argument, but it looks like it got through successfully. I would recommend some |
Your bash config is probably setting up an ssh-agent and your fish config is not. |
It's the other way around. My bash config is not setting up ssh-agent but fish does.
I am on Mac and I'll try to figure out if I could get any meaningful trace with |
If one shell has an ssh-agent and the other doesn't, that is the difference. It is not related to fish or bash specifically. |
just curious to know is this issue technically resolved per?: |
I'm getting this error not locally but in github actions, has anybody found any workaround for that case? |
I now appear to have an https:// style git url failing to install because cargo attempts to use the SSH version of the repo's url. Not sure how this happens though, or if the SSH version of the url has been cached or stored somewhere without my knowledge. |
Check for |
Interesting, I didn't find that, but using the regular git client I was
able to perform the update. I also found that the `branch="master"` setting
I had seemed to be the cause of the problem, but I haven't spent much time
on it as it was late and I got my build working again.
Thanks for the help!
…On Wed, 10 Apr 2024, 11:58 pm Ben Boeckel, ***@***.***> wrote:
I now appear to have an https:// style git url failing to install because
cargo attempts to use the SSH version of the repo's url.
Check for insteadOf configurations in Git that can rewrite URLs.
—
Reply to this email directly, view it on GitHub
<#1851 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIRUHQJTTYDK35XD4P7FSDY4VAONAVCNFSM4BMDVN4KU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBUG43DENBVHAZA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Right now there is no way for cargo to connect to a private repository, whether or HTTPS or SSH. I believe if the
git
Cargo.toml dependency option would support a non-URL string such asgit@github.com:user/repo
then the Git client in cargo would likely successfully connect.This is a major hole in cargo right now; I'm forced to submodule everything which is tedious.
Thanks in advance.
The text was updated successfully, but these errors were encountered: