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


当前回答

总是检查github ssh密钥生成程序,而不是一些过时的博客

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

在这里你可以看到键是通过以下方式生成的:

ssh-keygen -t ed25519 -C "your_email@example.com"

所以算法是ed25519而不是rsa或者别的什么。

其他回答

如果用户未生成之前设置的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

您可以在终端中执行以下操作:

cd ~ / . ssh ssh-keygen -o -t rsa -C "your@email.com" 当提示输入密钥保存位置时,输入:cat id_rsa。Pub | pbcopy 输入并确认您的密码,然后生成新的密钥。 通过运行cat ~/.ssh/id_rsa.pub通知github密钥 复制输出,然后转到github创建一个新的SSH密钥。粘贴复制的内容到文本区域,给它一个合适的标题,然后按ADD键。

现在你可以轻松地进行操作了。

在我的MAC中,我解决了这个问题:

cp ~/.ssh/github_rsa ~/.ssh/id_rsa

出于某种原因,我的git停止在github_rsa文件中寻找私钥。这发生在一次特定的回购中。我的意思是在其他存储库中git保持正常工作。

我想这是个bug。

我可以在运行ssh -vT git@github.com时发现这种行为

首先,我建议检查一些标准的东西,比如:

以正确的用户登录系统, 在系统的正确位置拥有正确的私钥, 尝试使用正确的用户名、主机名和端口进行连接, 将公钥放在外部服务器中正确的位置(并为正确的用户), 重新启动计算机上的SSH服务:

service ssh restart

(或者以另一种方式取决于您如何管理系统中的服务…)

这对我来说已经足够了。

在我的ubuntu系统中,我按照下面的步骤解决了这个问题。因为我正在尝试用无密码ssh到系统。

sudo vi /etc/ssh/sshd_config

1)评论如下: #更改为no禁用隧道明文密码 # PasswordAuthentication是的 PasswordAuthentication no ---->注释此。

2)然后重新启动sshd守护进程,如下所示。

重启SSHD服务