终端中Bitbucket登录认证失败,重装系统后克隆仓库报错
Bitbucket克隆仓库认证失败解决办法
错误信息
remote: Login failed due to incorrect login credentials or method. remote: If you are unsure of which login details or login method to use, visit: remote: https://support.atlassian.com/bitbucket-cloud/docs/log-into-or-connect-to-bitbucket-cloud/ fatal: Authentication failed for 'https://bitbucket.org/xxxxxxx/repository.git/'
解决步骤
验证账号密码有效性
先登录Bitbucket网页端确认账号密码正确。如果密码没问题,Bitbucket已不再支持直接用账号密码进行Git操作,必须改用App Password。创建并使用App Password
- 登录Bitbucket网页端,进入「个人设置」
- 找到「App passwords」选项,点击创建新密码
- 勾选克隆仓库所需的权限(至少选「Repository read」)
- 生成后复制该密码,克隆仓库时用它替代原账号密码
清理本地Git凭据缓存
重装系统后可能残留无效凭据,按系统类型执行对应操作:# Windows:用凭据管理器删除Bitbucket相关条目,或执行 git config --global credential.helper wincred # macOS:执行命令删除缓存 security delete-generic-password -s bitbucket.org # Linux:清理缓存 git credential-cache exit改用SSH克隆(替代方案)
若不想用HTTPS方式,可配置SSH密钥:- 生成SSH密钥对:
ssh-keygen -t ed25519 -C "你的邮箱地址" - 将生成的公钥(路径通常为
~/.ssh/id_ed25519.pub)添加到Bitbucket个人设置的SSH密钥列表中 - 使用SSH地址克隆:
git clone git@bitbucket.org:xxxxxxx/repository.git
- 生成SSH密钥对:
内容的提问来源于stack exchange,提问作者Niyaz
相关产品推荐
相关产品推荐

