moriturus / ktra

Your Little Cargo Registry
https://book.ktra.dev
Apache License 2.0
402 stars 38 forks source link

How to use SSH for Ktra config file #18

Open tomus85 opened 3 years ago

tomus85 commented 3 years ago

I am using GitLab self hosting (Got Gitlab set up on my Synology - been using it for years now)

Now I want to implement Ktra for my Rust projects.

I've got to this stage: https://book.ktra.dev/quick_start/create_ktra_configuration_file.html I tried:

https_username
https_password

However, because it is self-hosting I'm not using HTTPS, it just HTTP so this doesn't work.

So I tried to use SSH instead, so here is the file

[index_config]
remote_url = "ssh://git@<self-hosting-url>/crate/registry.git"
ssh_privkey_path = "~/.ssh/id_rsa.pub"
branch = "master"

When I do this:

Ktra -c ./cargo/ktra.toml

I get a message

Error: git error: username not defined

So I did the following:

git config --global user.name

I can see my username, but can't work out the problem. Am I missing any additional ssh fields in the .ktra.toml film?

tomus85 commented 3 years ago

I've been messing about again with it and noticed when I try this:

cargo login --registry=ktra

I get this

  failed to authenticate when downloading repository

  * attempted to find username/password via git's `credential.helper` support, but failed

  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:
  failed to acquire username/password from local configuration

How do I store the username and password in git's credential.helper config?

tomus85 commented 3 years ago

No worries, seem to have fixed it. I restarted my Mac then add the following

git config --global credential.helper osxkeychain

Everything is working now.