我有一个 gitea git 服务器,我也使用基本身份验证。 Web 访问工作正常,但是当我尝试通过 git 推送更改时,我似乎无法通过身份验证。
$ git push -u origin master
Username for 'https://example.com': myuser
Password for 'https://myuser@example.com':
remote: invalid credentials from <client-pub-ip>
fatal: Authentication failed for 'https://example.com/myuser/test.git/'
我还尝试使用 URI 中的基本凭据添加远程源(不安全!),但同样失败。
$ git remote add origin https://myuser:hunter2@example.com/myuser/test.git
$ git push -u origin master
remote: invalid credentials from <client-pub-ip>
fatal: Authentication failed for 'https://example.com/myuser/test.git/'
我不为 git 用户本身使用 2FA,只是简单的用户名/密码。
如何使用基本身份验证和 gitea 用户/密码将更改推送到我的服务器?
EDIT 基本身份验证根据服务器日志文件工作,所以我相信 git 尝试使用相同的凭据进行身份验证,但失败了。
EDIT2 如果我将 gitea 用户添加到 .htaccess
文件以进行基本身份验证,则 git push 工作正常。所以适当的问题是:
如何使用不同的凭据进行 git push 以进行基本身份验证和 gitea 服务器?
EDIT3 出乎我意料的是,基本认证和gitea用户的凭据相同,即使在浏览器中,基本认证也直接用于gitea的认证。注销不起作用,因为基本身份验证不会从浏览器中删除。