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


当前回答

伙计们我是这么干的

Open terminal and go to user [See attached image] Open .ssh folder and make sure it doesn't have any file like id_rsa or id_rsa.pub otherwise sometimes it wont properly rewrite files git --version [Check for git installation and version] git config --global user.email "your email id" git config --global user.name "your name" git config --list [make sure you have set your name & email] cd ~/.ssh ssh-keygen, it prompts for saving file, allow it cat ~/.ssh/id_rsa.pub [Access your public key & copy the key to gerrit settings]

注意:你不应该在Git中使用sudo命令。如果您有非常好的理由必须使用sudo,那么请确保您在每个命令中都使用它(此时使用su作为根来获取shell可能更好)。如果您不使用sudo生成SSH密钥,然后尝试使用sudo git push之类的命令,那么您将不会使用您生成的相同密钥

其他回答

$ cd ~
$ cd .ssh
$ chmod 400 id_rsa

除了Rufinus的回复,在Windows中将ssh密钥复制到剪贴板的快捷方式是:

id_rsa类型。Pub |剪辑

参考文献:

打印到标准输出 复制命令行输出到剪贴板

当我在工作中得到一台新电脑或换工作时,这些是我遵循的步骤。Mac或Windows

-访问https://github.[yourWorkDomain].com。导航到设置→开发人员设置→个人访问令牌 -生成一个新的令牌 -设置令牌描述,只检查范围的“repo”框(这将给你repo:status, repo_deployment, public_repo, repo:invite access)

-在你得到令牌后,复制它(不要导航离开,确认接下来的两步工作) -尝试再次克隆回购(使用“https”) -用户名使用你的用户名 -对于密码,粘贴您复制的令牌 -所有未来的请求现在应该工作,而不需要您的用户名和密码。

基本的GIT指令没有引用SSH密钥之类的东西。沿着上面的一些链接,我发现了一个git帮助页面,它一步一步地解释了如何在各种操作系统上做到这一点(链接将检测您的操作系统并相应地重定向):

http://help.github.com/set-up-git-redirect/

它介绍了GITHub所需的所有内容,并给出了详细的解释,例如“为什么在创建RSA密钥时添加密码短语”。我想我应该把它贴出来,说不定能帮助到别人……

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

sudo vi /etc/ssh/sshd_config

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

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

重启SSHD服务