..

authentication error for ssh:// in Cargo project

  • 现象

cargo update ,更新 private 库,提示:

Caused by:
  failed to load source for dependency `xxx`

Caused by:
  Unable to update ssh://git@github.com/xxx

Caused by:
  failed to fetch into: /home/u20/.cargo/git/db/xxx-dc42410e9bb777d4

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:
  error authenticating: no auth sock variable; class=Ssh (23)
  • 解决
eval `ssh-agent -s`
ssh-add
cargo update