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 |
|
Here's what worked for me on MacOS Mojave.
Then Cargo was able to pull the crate from there. It worked with and without the following addition to the but I put it in, so it will probably stay there, unless I find a reason to remote it. I also had added to |
|
@akshayknarayan 's issue above is #7202, which is fixed by #7238 . Not sure how to figure out which release that fix will be in though? Seems at least 0.40: |
|
So I had an issue with using a forwarded ssh agent (through pythons paramiko SSH implementation) with Cargo. The Any hint on how to debug this would be appreciated. There's some more info on my problem here: paramiko/paramiko#1626 |
|
The git cli does not use libgit2. |
|
I could not fix the issue. So I cloned repository and used direct path in config |
|
Related to "invalid port" error, I have urls of this style (thanks to azure devops): If I use that format, it fails with "relative URL without a base". If I prepend "ssh://" it fails with "invalid port" (:v3). Of course |
|
Struggled with this, turns out that I needed to add my ssh keys to the ssh-agent with The reason I don't need to do this for the You can check whether you have non-default ssh keys by running: $ grep IdentityFile ~/.ssh/config | sort -u
IdentityFile ~/.ssh/gibfahn_id_ed25519
IdentityFile ~/.ssh/gibfahn_id_rsaand then add them with: $ ssh-add ~/.ssh/gibfahn_id_ed25519 ~/.ssh/gibfahn_id_rsa |
That's the one. Thanks! |
Try to replace ":" with "/". It works for gitlab. |
|
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 |
|
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. |
Right now there is no way for cargo to connect to a private repository, whether or HTTPS or SSH. I believe if the
gitCargo.toml dependency option would support a non-URL string such asgit@github.com:user/repothen 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: