vscode+github+远程服务器报错以及修复

vscode+github+远程服务器报错以及修复

提交cs61c的lab2时,git push 报错如下:

(23:30:00 Wed Sep 11 2024 cs61c-att@solano Linux x86_64)
~/lab/lab02 $ git push
Missing or invalid credentials.
Error: connect ECONNREFUSED /run/user/97156/vscode-git-a2ecc140f1.sock
    at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1606:16) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '/run/user/97156/vscode-git-a2ecc140f1.sock'
}
Missing or invalid credentials.
Error: connect ECONNREFUSED /run/user/97156/vscode-git-a2ecc140f1.sock
    at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1606:16) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '/run/user/97156/vscode-git-a2ecc140f1.sock'
}
remote: No anonymous write access.
fatal: Authentication failed for 'https://github.com/61c-teach/fa24-lab-starter.git/'

复盘+解决方案如下:

1. vscode中git插件

首先怀疑到vscode中的git插件出错。
因为在git bash中,报错信息不是完全相同。

$ git push
Username for "https:/github.com': 
Password for 'https://su-jiagidgithub.com':
remote: support for password authentication was removed on August 13, 2021
remote: please see https://docs.github.com/get-started/getting-started-with-gitabout-remote-repositories#cloning-with-https-urls for information on currentlyecommended modes of authentication.
fatal: Authentication failed for https://github.com/xxx

2. vscode污染ssh公钥

怀疑vscode由于某些原因污染了公钥等。
具体原因仍不是很清楚,保险起见换个新的
但是重新keygen了公钥,并且添加至github上。

3. 采用git bash

放弃vscode终端,采用git bash终端。规避掉vscode由于插件或什么原因造成的错误。

之后发现权限问题解决了:

git ls-remote git@github.com:xxx

该命令可以正常运行。

4. origin未被默认

现在遇见的问题是:虽然我的remote -v对应的都是ssh了,但是它连接的第一步看的还是https,然而众所周知github的https密码验证在2021年后就禁用了

git pushUsername for 'https://github.com': 
Password for 'https:su-jiagidgithub.com'
remote: support for password authentication was removed on August 13, 2021.
remote: please see https://docs.github.com/get-started/getting-started-with-gitabout-remote-repositories#cloning-with-https-urls for information on currentiyecommenced moces of authentication.
fatal: Authentication failed for "https://github.com/xxx

git remote -v的结果是:

$ git remote -v
origin git@github.com:xxx(fetch)
origin git@github.com:xxx (push)
starter https://github.com/xxx(fetch)
starter https://github.com/xxx(push)

这两个对比就说明:电脑里需要写明origin是什么,可能是因为没有做过全局配置
所以写git pull 或者 push时需要完整命令:

git pull origin main
git push origin main
 

问题解决!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值