我有一个公共回购,https://github.com/rlpowell/config.我曾经能够在没有任何ssh密钥(即来自cron)的情况下运行git pull,并且使用git@github.com:rlpowell/config.git URL(即SSH URL)工作正常.这不再有效,我不知道为什么,但它确实适用于我的两个朋友.
我希望能够在没有ssh密钥的情况下使用公共仓库,或者至少理解为什么它对我不起作用而且对其他人起作用.
这是一个尝试我的测试用例的朋友:
$ git clone git@github.com:rlpowell/config.git ; cd config ; (unset SSH_AUTH_SOCK ; ssh-add -l ; git pull )
Cloning into 'config'...
Warning: Permanently added the RSA host key for IP address '192.30.253.113' to the list of known hosts.
remote: Counting objects: 1061, done.
remote: Total 1061 (delta 0), reused 0 (delta 0), pack-reused 1061
Receiving objects: 100% (1061/1061), 544.42 KiB | 495.00 KiB/s, done.
Resolving deltas: 100% (632/632), done.
Checking connectivity... done.
Could not open a connection to your authentication agent.
Already up-to-date.
Run Code Online (Sandbox Code Playgroud)
这是我做同样的事情:
$ git clone git@github.com:rlpowell/config.git ; cd config ; (unset SSH_AUTH_SOCK ; ssh-add -l ; git pull )
Cloning into 'config'...
remote: Counting objects: 1061, done.
remote: Total 1061 (delta 0), reused 0 (delta 0), pack-reused 1061
Receiving objects: 100% (1061/1061), 544.42 KiB | 0 bytes/s, done.
Resolving deltas: 100% (632/632), done.
Checking connectivity... done.
Could not open a connection to your authentication agent.
Enter passphrase for key '/home/rlpowell/.ssh/id_rsa':
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
(我在ssh密钥密码提示下按Enter键).
在repo中,.git/config是:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@github.com:rlpowell/config.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
Run Code Online (Sandbox Code Playgroud)
而git config -l是:
$ git config -l
user.email=rlpowell@digitalkingdom.org
user.name=Robin Lee Powell
push.default=matching
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@github.com:rlpowell/config.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
Run Code Online (Sandbox Code Playgroud)
git版本是2.5.5
strace说实际运行ssh的东西是
ssh git@github.com git-upload-pack 'rlpowell/config.git'
Run Code Online (Sandbox Code Playgroud)
小智 12
尝试先运行此命令:
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no github.com
Run Code Online (Sandbox Code Playgroud)
再git pull一次.
Von*_*onC 10
我只是尝试了没有密钥,我确认它无法工作(没有SSH密钥):
$ git clone git@github.com:rlpowell/config.git
Cloning into 'config'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
这是因为GitHub不会通过SSH授权匿名访问(而不是https),因为其他git repo服务器决定这样做(如Gogits或go-gitea)
GitHub 确实提到:
SSH URL通过SSH(一种安全协议)提供对Git存储库的访问.
要使用这些URL,您必须 在计算机上生成SSH密钥对,并将公钥添加到您的GitHub帐户.
(强调必须)
为什么?(在2015年问).虽然可以将sshd配置为允许匿名访问,但是没有公共站点会考虑设置它:它的安全风险太大了.
需要在没有特定密钥的情况下工作
如果您需要匿名访问,可以使用:
git://github.com/<user>/<repo>虽然它使用的是端口9418,它通常在企业环境中被阻止.它是一个公共 GitHub 存储库,您只想从中提取,因此您可以使用 HTTPS URL:
https://github.com/rlpowell/config.git
Run Code Online (Sandbox Code Playgroud)
问题似乎出在 ssh 密钥上,至少回复说:
Enter passphrase for key '/home/rlpowell/.ssh/id_rsa':
Permission denied (publickey).
Run Code Online (Sandbox Code Playgroud)
所以你需要将你的公钥添加到github
您也可以运行:
ssh -T git@github.com
Run Code Online (Sandbox Code Playgroud)
检查 ssh 与 github 的连接
| 归档时间: |
|
| 查看次数: |
7829 次 |
| 最近记录: |