我用的是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没有密码,但仍然错误。


当前回答

我已经使用gh进行了身份验证,创建了新的密钥,等等。问题是我在Ubuntu中安装了带snap的gh,所以生成的新密钥在。/snap/gh/502/。Ssh /,而不是常规的. Ssh路径。

我解决了它复制一切到。ssh文件夹:

cp -a ./snap/gh/502/.ssh/* .ssh/

如果没有,用find找到你的钥匙。- name * .pub

我想,在数字世界里,知道你把钥匙放在哪里仍然是个问题。

其他回答

这些是我在windows 10中遵循的步骤

打开Git Bash。 生成公钥: ssh-keygen -t rsa -b 4096 -C "youremailaddress@xyz.com" 复制生成的键到剪贴板(像CTRL+C一样工作) 剪辑< ~/.ssh/id_rsa.pub 浏览器,进入Github => Profile=> Settings => SSH和GPG Key => Add Key 提供键名和粘贴剪贴板(CTRL+V)。 最后,测试您的连接(Git bash) ssh -T git@github.com

谢谢!

如果用户未生成之前设置的ssh公私钥对

此信息在聊天上工作,但可以应用于所有其他支持SSH pubkey身份验证的git存储库。(参见[gitolite][1], gitlab或github。)

首先设置您自己的公钥/私钥对集。这 可以使用DSA或RSA,所以基本上你设置的任何密钥都可以工作。 在大多数系统上,您可以使用ssh-keygen。

First you'll want to cd into your .ssh directory. Open up the terminal and run: cd ~/.ssh && ssh-keygen Next you need to copy this to your clipboard. On OS X run: cat id_rsa.pub | pbcopy On Linux run: cat id_rsa.pub | xclip On Windows (via Cygwin/Git Bash) run: cat id_rsa.pub | clip On Windows (Powershell) run: Get-Content id_rsa.pub | Set-Clipboard (Thx to @orion elenzil) Add your key to your account via the website. Finally setup your .gitconfig. git config --global user.name "bob" git config --global user.email bob@... (don't forget to restart your command line to make sure the config is reloaded) That's it you should be good to clone and checkout.

更多信息请访问https://help.github.com/articles/generating-ssh-keys(感谢@Lee Whitney) [1]: https://github.com/sitaramc/gitolite

-

如果用户已经生成了之前设置的ssh公私钥对

检查哪个密钥已被授权在您的github或gitlab帐户设置 确定必须从本地计算机关联哪个相应的私钥

Eval $(ssh agent -s)

定义键的位置

ssh-add ~ / . ssh / id_rsa

我遇到了同样的问题,因为我认为SSH和HTTPS之间的区别是

https://github.com/USERNAME/REPOSITORY.git

ssh: / / github.com/USERNAME/REPOSITORY.git

因此,我从HTTPS更改为SSH,只需将https://更改为SSH:// url的末尾没有任何变化。

但事实是:

https://github.com/USERNAME/REPOSITORY.git

git@github.com:USERNAME/REPOSITORY.git

这意味着我将ssh://github.com/USERNAME/REPOSITORY.git更改为git@github.com:USERNAME/REPOSITORY.git。

愚蠢的错误,但希望能帮助某人!

这对我来说很管用:

ssh-add ~/.ssh/id_rsa

在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密钥的版本工具。使用“添加键选项”粘贴内容

就是这样。试着现在就做出承诺和努力。