62

I followed everything in the GitHub tutorial: https://help.github.com/articles/generating-ssh-keys

I did all the commands in the directory of my repository. I reached the end of tutorial successfully and got the message: "Hi username! You've successfully authenticated, but GitHub does not # provide shell access."

However when I tried to do things such as push it still requested for my username and password.

4

4 回答 4

182

remote通过.检查您的 s git remote -v

https://除非您配置凭据助手,否则 URL 将始终要求输入密码。有关此问题的更多信息。

无密码 git 访问的最简单解决方案是使用该git remote set-url命令并为现有 repo 设置一个SSH url。

在你的情况下,git remote set-url origin git@github.com:name/repo.

然后,您应该能够在git push origin <branch>不被要求输入密码的情况下进行操作。

于 2013-09-14T04:24:09.017 回答
19

很好,您已经正确设置了 git ssh,现在您需要使用 ssh 重新克隆 g​​it 存储库,例如以前您会执行以下操作:

git clone https://github.com/dangrossman/bootstrap-daterangepicker.git

这是一个 https 克隆,现在您需要使用 ssh 进行克隆

git clone git@github.com:dangrossman/bootstrap-daterangepicker.git

您可以从您的 github 帐户中找到 ssh 链接,与您找到 https 链接的位置相同。在此之后,您可以在没有密码提示的情况下轻松推送。

它可能会询问您的 ssh 解锁密码。然后,您需要输入您在创建 ssh 密钥期间给出的副阶段。如果您将其留空,它可能不会提示您输入它。

于 2013-09-14T03:25:09.133 回答
3

.git/config通过从基本 repo 目录打开并更改远程 URL,我能够停止用户名和密码提示。

例如:

[remote "origin"]
    url = https://github.com/username/my-repo.git

应改为:

[remote "origin"]
    url = git@github.com:username/my-repo.git
于 2019-10-25T02:13:58.233 回答
1

我尝试了标记为正确的答案,但无法正常工作。这对我有用git remote set-url origin ssh://git@github.com/username/reponame

于 2020-10-29T05:34:46.057 回答