在Dreamhost中从SSH执行'git pull'到没有密码的GitHub

Jsu*_*alv 4 git ssh github dreamhost ssh-keys

我在使用git命令(例如git pull)时遇到困难,而不必使用GitHub输入用户名和密码.

我可以通过SSH连接到我的Dreamhost服务器并手动运行git pull.然后我必须输入我的GitHub用户名和密码.这是罚款和花花公子,但我想运行git pull WITHOUT不必输入我的GitHub的凭据每次.

发现我需要添加SSH密钥,但服务器仍然要求GitHub凭据.

我做了以下事情:

  1. 使用PuTTy SSH进入Dreamhost共享服务器

  2. 做了以下事情:

$ 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
Run Code Online (Sandbox Code Playgroud)
  1. 复制/.ssh/id_rsa.pub密钥并将其添加到"部署密钥"部分@ GitHub.com
  2. 回到Dreamhost服务器,我用git repo SSH进入目录(例如/ home/funkyserver/mysite)
  3. git pull,它仍然要求我输入凭据的GitHub

我在SSH密钥上做错了什么?我没有正确生成它们吗?我没有正确地将它们添加到GitHub吗?

请帮忙.

小智 9

试着做git remote -v.

如果您的遥控器以前缀https://为密码将被要求.

您可以使用切换到ssh协议git remote set-url origin git@github.com:username/repo.git

这个问题Github上有更多信息