You‘ve successfully authenticated, but GitHub does not provide shell access.问题解决

文章描述了一位用户在配置了SSH密钥后,尝试gitpush时遇到GitHub不再支持密码认证的问题。解决方案包括使用个人访问令牌和更改远程仓库URL为SSH格式。用户需按照提示切换到token认证,或者将远程仓库的URL从HTTPS改为SSH来避免输入账号密码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题与原因

https://github.com/settings/keys已经配置了本地的git 通过git-keygen -t rsa命令生成的秘钥已经配置,而使用 ssh git@github.com命令得到如下的反馈

$ ssh -T git@github.com
Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.

这时候只看到successfully以为已经配好了密钥,以后项目都可以连接github了,但其实后面 does not provide shell access告知了不可以使用shell访问。
然后使用项目在git push 的时候将还是会提示输入账号密码。并且现在 git 也不允许 http 连接,所以提供账号密码也没办法 push。

$ git push -u origin main
Username for 'https://github.com': xxx@qq.com
Password for 'https://xxx@qq.com@github.com': 
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/xxx/xxx.git/'

这一段的意思你原先的密码凭证从2021年8月13日开始就不能用了,必须使用个人访问令牌(personal access token),就是把你的密码替换成token

解决方案

  1. 第一种是根据提示的来使用token的解决方案:作者在这篇文章有提供解决github配置ssh密钥后仍然需要登录
  2. 第二种可以通过以下命令添加远程仓库
git remote set-url origin git@github.com:用户名/仓库名.git

注意这里并非普通的http格式添加远程仓库
然后查看远程仓库可以发现已经改变了格式:

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AlwaysDayOne

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值