我用的是Mac雪豹,刚刚安装了git。
我只是试了
git clone git@thechaw.com:cakebook.git
但这给了我这个错误:
Initialized empty Git repository in `/Users/username/Documents/cakebook/.git/`
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
我错过了什么?
我也试过做ssh-keygen没有密码,但仍然错误。
Windows上的另一种可能性,在这些答案中都没有涉及,git或github文档中也没有涉及故障排除:
Git使用的openssh可执行文件可能与您认为的不同。
当我试图从github和ssh.dev.azure.com克隆或拉时,我收到了权限拒绝(公钥)错误,我遵循了所有的说明,并验证我的SSH密钥被正确设置(从SSH的立场)使用SSH -vT git@github.com和SSH -vT git@ssh.dev.azure.com。并且仍然得到这些错误:
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我最终发现问题在于Git for Windows和Windows都有自己的openssh版本。这里有文档:https://github.com/desktop/desktop/issues/5641
我依赖于Windows的ssh-agent服务来存储我的ssh密钥密码,所以git(使用它的单独版本的openssh)无法读取我的私钥。我认为这是一个错误,这个错误信息被使用-它是误导性的。
解决方案是:
git config --global core.sshCommand "'C:\Windows\System32\OpenSSH\ssh.exe'"
或者在~/.gitconfig中:
[core]
sshCommand = 'C:\\Windows\\System32\\OpenSSH\\ssh.exe'
也许git很快就会修复这个问题,但这已经是我第二次在这个问题上浪费时间了。
在MAC中,进入终端
1)使用命令- cd ~进入主目录
2) cd .ssh && ssh-keygen(默认情况下,双击输入/返回键)
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/usernmae/.ssh/id_rsa.
3)之后,做“ls”。您将找到id_rsa。酒吧文件。
4)复制id_rsa. conf文件中的内容。Pub文件(使用cat命令读取- cat id_rsa.pub)
5)导航到BitBucket或任何支持SSH密钥的版本工具。使用“添加键选项”粘贴内容
就是这样。试着现在就做出承诺和努力。