GitLab SSH Key 过期:git pull failed : remote your ssh key has expired

第一步:生成新的 SSH 密钥

由于旧的密钥已过期,需要在本地重新生成一个。

在 Git Bash 中执行:

邮箱换成你的 GitLab 账号邮箱

bash 复制代码
ssh-keygen -t ed25519 -C "your_email@example.com"

第二步:如果是第二次修改生成publishKey

方法一:创建或修改 ~/.ssh/config 文件,强制指定该域名使用新密钥。

bash 复制代码
notepad ~/.ssh/config

在文件config中添加:

bash 复制代码
Host gitlab.com.cn(此处是自己的gitlab全域名不同公司可能有代理)
HostName gitlab.com.cn
User git
IdentityFile ~/.ssh/id_ed25519

方法二:简单粗暴法(删除旧密钥)

如果旧密钥(通常是 id_rsa)不再被其他服务器使用,直接删除:

清理一下 ssh-agent 的缓存

bash 复制代码
rm ~/.ssh/id_rsa ~/.ssh/id_rsa.pub
ssh-add -D
相关推荐
GHL2842710909 小时前
git cherry-pick使用
git
小龙11 小时前
【Git 报错解决】本地分支与远程分支名称/提交历史不匹配
大数据·git·elasticsearch·github
阿正的梦工坊11 小时前
Git Rebase 是什么?为什么需要它?
人工智能·git
ASEpochs13 小时前
Vsocde中‘sh’不是内部或外部命令,也不是可运行的程序或批量处理文件--已解决
git·vscode·bash
coding消烦员13 小时前
在 Windows 内网搭建 Git 仓库:共享普通仓库 vs 中心 bare 仓库
windows·git
李@十一₂⁰14 小时前
git多分支管理
大数据·git·elasticsearch
爱写代码的派大星15 小时前
git 拉取和合并
git
Kp独立开发17 小时前
开源项目二次开发最佳实践:Fork + 分支隔离与同步
git·开源
Galaxy~56720 小时前
Git常见命令及用法
大数据·git·elasticsearch
噎住佩奇1 天前
Shell提示符变为bash-4.2
linux·ssh