情况
git的版本是git version 2.34.1.windows.1
电脑的window版本是window10专业版,已经配置好git以及其他设置。
问题描述
首先我在运用pycharm的push仓库的时候出现了这个问题。
ERROR: Permission to pytorch/text.git denied to LucasandElliot. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. |
错误:对 pytorch/text.git 的权限被拒绝LucasandElliot。 致命:无法从远程存储库读取。 请确保您拥有正确的访问权限 并且存储库存在。 |
后续还出现了以下问题,但是解决方法(已解决)和途径如下所示。
Warning: Permanently added 'git.coding.net,222.186.133.56' (RSA) to the list of known hosts.
Warning: Permanently added '...' (RSA) to the list of known hosts --Windows下git bash
解决 Coding使用Git出现:Permission denied (publickey).
Warning: Permanently added ‘github.com’ (ED25519) to the list of known hosts. [email protected]
使用Git时报错Connection reset by 20.205.243.166 port 22
搜索到的解决办法
这里我首先借鉴了以往的经验解决办法如下:
重新配置ssh,更换coding,github,gitee上的ssh。(尝试无效),但是下面有ssh配置以及参考。
更换,配置端口(没有尝试)
更换手机热点,原因有可能跟内网有关(尝试无效)
更换请求方式,换成https请求(没有尝试,但这个用https应该可以)
关闭代理和VPN(有效,解决了Connection reset by 20.205.243.166 port 22)
我的解决办法如下所示,在C:\Users\xxx\.ssh(xxx为用户名)的目录下生成一个config文件(名字名称直接叫做config,没有后缀,如图所示),可用记事本打开,添加一部分代码(主要用于解决github和coding上的拖拉仓库)或者是用gitbash(终端)打开进行修改。除此之外,就是找到C:\Program Files\Git\etc\ssh(每个人安装Git的地方下的etc\ssh),下面再多加上下面介绍步骤代码。(照猫画虎即可)(下面有展示)
解决办法(成功办法)
在C:\Users\xxx\.ssh(xxx为用户名)的目录下生成一个config文件(名字直接叫做config,而且没有后缀)添加以下内容(主要用于解决github和coding上的拖拉仓库)
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github
# coding
Host e.coding.net
HostName e.coding.net
PreferredAuthentications publickey
IdentityFile ~/.ssh/modeling
# 如果生成多个 SSH-Key , 则按上面的格式继续往下写
内容模板
# coding
Host e.coding.net # 网址或者网站,去除https/http
HostName e.coding.net # 网址或者网站,去除https/http
PreferredAuthentications publickey
IdentityFile ~/.ssh/modeling # 生成或者需要的.pub文件的名称
2. 就是找到C:\Program Files\Git\etc\ssh(每个人安装Git的地方下的etc\ssh),下面再添加上类似的代码。(照猫画虎即可)
Host *.coding.net # 这里放置Host *.xxx.com
HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
配置ssh
前提是安装好git,而且能够出现以下界面即可,随即输入以下命令,下面有可以直接复制,而且有做解释。
cd ~/.ssh # 切换路径
ls # 查看是否存在id_rsa 和 id_rsa.pub文件
ssh-keygen -t rsa -C "[email protected]" # 如果不存在id_rsa,id_rsa.pub,或者我们也可以覆盖掉
出现下面提示我们可以根据自己需要进行修改
Enterfile in which to save the key (/Users/you/.ssh/id_rsa): [Press enter] // 推荐使用默认地址,但是我们可以自己命名pub文件名称,方便区分和设置多个ssh
Enterpassphrase (empty for no passphrase): //此处直接回车即可;若设置密码,则每次使用 SSH 方式推送代码时都会要求输入密码
Enterpassphrase again
出现下面界面,(pub为公钥,无后缀为私钥)代表ssh创建成功。
之后再输入以下代码,出现下面一长串的内容到github或者gitee的setting的ssh部分,新建ssh即可。
cd ~/.ssh
cat example.pub
最后在测试一下是否能够连接得上github.com或者是gitee.com即可。
ssh -T [email protected]
成功的界面如下。即为证明可以进行拖拉仓库而且跟github或gitee上建立连接成功。
参考
coding配置ssh文档:https://coding.net/help/docs/repo/ssh/config.html
https://blog.csdn.net/qq_42203909/article/details/120346639
https://blog.csdn.net/zhangyiminsunshine/article/details/121237492