使用SSH的GitHub克隆存储库不起作用 [英] GitHub clone repositories with SSH doesn't work
问题描述
git clone git@github.com:Xingggg / Material-Design-Study-Notes.git
终端出错信息:
ssh_exchange_identification:由远程主机关闭的连接
致命:无法从远程存储库读取。
请确保您拥有正确的访问权限
并存在存储库。
我在我的GitHub帐户中添加了公钥。 p>
我使用 HTTPS
克隆存储库即可。
我的机器是MacBook Pro
声音就像你没有正确设置你的ssh密钥,或者它们可能被撤销,你不能使用它们。 b
我使用https clone repo它没问题
https
使用用户名密码而不是ssh。设置钥匙并将遥控器切换到ssh。
如何设置:
-
生成一个新的ssh键(或者如果你已经有一个键,就跳过这一步)
ssh-keygen -t rsa -Cyour @ email
-
在
home / .ssh
目录(或用户/<你的用户> .ssh
在windows下),打开并复制内容
如何在你的GitHub账户下设置ssh密钥?
$ b
- 登录GitHub账户
- 点击右上方的牧场主( /TsfLJ.pngrel =nofollow noreferrer>
- 点击
SSH密钥d GPG钥匙
- 点击
新建SSH密钥
- 粘贴您的密钥并保存
现在它应该可以工作了
在第一次设置开放式终端并运行 git fetch
这样键就会被测试并添加到您的已知主机
文件中。
Type command:
git clone git@github.com:Xingggg/Material-Design-Study-Notes.git
Terminal error message:
ssh_exchange_identification: Connection closed by remote host fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
I have added my public key in my GitHub account.
I use HTTPS
clone repositories it's OK.
My machine is MacBook Pro
Sound like you have not set up your ssh keys properly or they might be revoked and you cant use them.
And I use https clone repo It's ok
https
use username password and not ssh. Set the keys and switch the remote to ssh.
Here is how to set it up:
Generate a new ssh key (or skip this step if you already have a key as you mentioned )
ssh-keygen -t rsa -C "your@email"
Once you have your key set in
home/.ssh
directory (orUsers/<your user>.ssh
under windows), open it and copy the content
How to set up ssh key under your GitHub account?
- Login to GitHub account
- Click on the rancher on the top right (
Settings
)
- Click on the
SSH keys and GPG Keys
- Click on the
New SSH key
- Paste your key and save
Now it should work
Note
After the first set up open terminal and run a git fetch
so the key will be tested and added to your known hosts
file.
这篇关于使用SSH的GitHub克隆存储库不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!