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
相关推荐
一颗小行星!3 小时前
快速理解 Git submodule
git
有理想的打工人3 小时前
gitlab的参数设置与团队管理
gitlab
Zhu7585 小时前
【软件更新】在Ubuntu24 LTS中更新openssl到指定版本,例如openssl3.5.6 LTS
linux·ssh·ssl
有理想的打工人5 小时前
gitlab群组管理与ssh链接
ssh·gitlab
A-Jie-Y5 小时前
Git基础-核心概念与常用命令
git
夜珀6 小时前
Git基础修炼手册:在AtomGit上玩转版本控制
git
M-Ellen6 小时前
从零搭建 Windows + WSL2 + Docker + GitLab CI/CD 完整手册
ci/cd·docker·gitlab
golang学习记6 小时前
Zed IDE官宣新招:Git Graph 正式支持!
ide·git
要记得喝水6 小时前
适用于 Git Bash 的脚本,批量提交和推送多个仓库的修改
git·elasticsearch·bash
AI_Claude_code7 小时前
专栏导论:开源项目贡献的价值与Git工作流全景图
git·开源