如果不提供用户名就无法通过 git 进行克隆

如果不提供用户名就无法通过 git 进行克隆

通常我会做git clone myusername@bitbucket...`` I have cleaned out~/.ssh` 我根据

我希望能够使用仅进行克隆git@bitbucket... 但这总是给我一个错误,即使我有一个公钥(并且我已经将公钥添加到bitbucket):

Warning: Permanently added the RSA host key for IP address 'xxx.xxx.xxx.x' to the list of known hosts.
repository access denied.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.



git config --list

credential.helper=osxkeychain
[email protected]
user.name=XX XX
core.excludesfile=/Users/daka/.gitignore_global
core.compression=0
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Users/daka/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
commit.template=/Users/daka/.stCommitMsg
credential.helper=osxkeychain

答案1

尝试在此处将您的公共 RSA 密钥添加到 bitbuckethttps://bitbucket.org/account/user/用户名/ssh-keys/

用您的用户名更改username

更新 1:

如果没有定义方案,Git 将使用 SSH 协议,就像在您的帖子中一样。它会尝试通过 SSH 为用户或您[email protected]连接到 bitbucket 的 git shell并获取。gitusername<username>/<reponame>.git

要调试连接,请使用GIT_SSH_COMMAND="ssh -v"beforegit clone命令。尝试为您usernamegit用户。并找出这些连接之间的差异。

一些正常连接的调试消息来自:GIT_SSH_COMMAND="ssh -v" git clone [email protected]:username/reponame.git

...
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:Gpy/VA4ng...
debug1: Server accepts key: pkalg ssh-rsa blen 279
Enter passphrase for key '/home/username/.ssh/id_rsa': 
debug1: Authentication succeeded (publickey).
Authenticated to bitbucket.org ([104.192.143.3]:22).
...
debug1: Entering interactive session.
...
debug1: Sending command: git-upload-pack 'username/reponame.git'
remote: Counting objects: 96, done.
remote: Compressing objects: 100% (93/93), done.
...

服务器接受我的连接,因为它知道我的公共 SSH 密钥。

相关内容