我在无需 GitHub 输入用户名和密码的情况下通过 SSH 执行 git 命令(例如 git pull)时遇到困难。
我可以通过 SSH 连接到我的 Dreamhost 服务器并手动运行 git pull
。然后我必须输入我的 GitHub 用户名和密码。这很好,但我想运行 git pull
WITHOUT 每次都必须输入我的 GitHub 凭据。
发现我需要添加 SSH key ,但服务器仍然要求提供 GitHub 凭据。
我做了以下事情:
使用 PuTTy 通过 SSH 连接到 Dreamhost 共享服务器
做了以下事情:
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/funkyserver/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): <-- I left this empty
Enter same passphrase again: <-- I left this empty
Your identification has been saved in /home/funkyserver/.ssh/id_rsa.
Your public key has been saved in /home/funkyserver/.ssh/id_rsa.pub.
The key fingerprint is:
12:c3:12d:88:01:pp:12:b5:ca:33:8g:1q:64:ce:4a:81 funkyserver@wonkyninja <-- wonkyninja is Dreamhost's server name and this fingerprint is fake
The key's randomart image is: <-- I left this part out on purpose
- 复制/.ssh/id_rsa.pub key 并将其添加到“部署 key ”部分@ GitHub.com
- 回到 Dreamhost 服务器,我通过 SSH 进入带有 git repo 的目录(例如/home/funkyserver/mysite)
- 运行
git pull
,它仍然要求我输入 GitHub 凭据
我在使用 SSH key 时做错了什么?我没有正确生成它们吗?是我没有把它们正确地添加到 GitHub 吗?
请帮忙。
最佳答案
尝试执行 git remote -v
。
如果您的 Remote 以 https://
为前缀,系统会要求您输入密码。
您可以使用 git remote set-url origin git@github.com:username/repo.git
ssh
协议(protocol)
this question中有更多信息和 Github
关于git - 从 Dreamhost 中的 SSH 执行 'git pull' 到 GitHub 没有密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18500615/