-
Unbantu系统
-
git 生成ssh密钥(先检查是否已经有)
-
如果没有id_dsa.pub,则需要生成(邮箱名为授权拉取代码的邮箱)
ssh-keygen -t rsa -C 'xx@xx.com'
-
查看ssh密钥并全部复制
cat ~/.ssh/id_rsa.pub
-
一般情况这样就可以了,但是如果报错为:
The authenticity of host '[git.mioffice.cn]:29418 ([10.142.196.21]:29418)' can't be established. RSA key fingerprint is SHA256:iLyah8Dxi5hhuy/LC0DAwatACBwYR5ptFj07MWaI1w8. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '[git.mioffice.cn]:29418,[10.142.196.21]:29418' (RSA) to the list of known hosts. sign_and_send_pubkey: signing failed: agent refused operation Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.、
-
先去工程目录下找到隐藏 .git文件夹(ubuntu下 ctrl+h) ,然后打开,找到config文件并编辑
url = xxx...gerrit.pt.mioffice.cn:...xxxx
-
则需要添加sshkey至ssh-agent
(1)执行eval “$(ssh-agent -s)”确认ssh-agent处于开启状态,打印pid... 表示启用中; (2)执行指令ssh-add ~/.ssh/id_rsa 添加ssh key至ssh agent
-
最后执行clone命令即可
-
windows
1.生成
ssh-keygen -t ed25519 -C "email@example.com"
2.复制
cat ~/.ssh/id_ed25519.pub | clip
3.添加到 gitlab 等
3.验证
ssh -T git@gitlab.com (gitlab.com替换为自己的 例如gitlab.ziroom.com)
- 查看失败原因
ssh -vvv git@gitlab.com
- 升级mac版本带来的git问题
主要提示失败信息为:send_pubkey_test: no mutual signature algorithm
debug1: Server host key: ssh-ed25519
原因:OpenSSH 版本太高
解决方案:更换秘钥生成算法,使用 ed25519 算法生成
ssh-keygen -t ed25519 -C "your email"
最后注意 cat id_ed25519.pub 而不是 id_rsa.pub