原因是1.7.x版.ssh/config 中的IdentityFile设为id_rsa.pub,而2.x版的是要设为id_rsa, 编辑当前用户的.ssh/config
vi ~/.ssh.config
Host x.x.x.x
User git
IdentityFile /home/xxx/.ssh/id_rsa
IdentitiesOnly yes
其中x.x.x.x为目录git服务IP地止,xxx为当前用户目录.
参考:https://stackoverflow.com/questions/48328446/id-rsa-pub-file-ssh-error-invalid-format