||
最近使用GitHub辅助教学。前几周还好好的,但这两周来,本地Eclipse里写的教学示例脚本要记录并推送(Commit and Push)到GitHub时却总是失败。返回信息如下:
Can't connect to any repository: git@github.com:yadebaba/BPUP.git (git@github.com:yadebaba/BPUP.git: ERROR: You're using an RSA key with SHA-1, which is no longer allowed. Please use a newer client or a different key type.
Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.
网上一搜,不少人最近也遇到了类似问题。其中,更新客户端的方案大多失败告终。Stackoverflow上网友gbark使用ECDSA的换键解决方案,在scs v2.1中测试成功。我参考其方案,移植用于Eclipse,也成功解决了问题。步骤如下:
1、获得hostkey。在Shell中输入命令 ssh-keyscan -t ecdsa github.com 以获得GitHub主机的hostkey值,屏幕显示
# github.com:22 SSH-2.0-babeld-4f04c79d
github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=
这个值应该也添加到主目录里.ssh文件夹的known_hosts文件里了。
2、生成新键。 在Shell中输入命令 ssh-keygen -t ecdsa -b 256 -m PEM。一路回车,屏幕交互信息如下
Generating public/private ecdsa key pair.
Enter file in which to save the key (/home/me/.ssh/id_ecdsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/me/.ssh/id_ecdsa
Your public key has been saved in /home/me/.ssh/id_ecdsa.pub
The key fingerprint is: .......
The key's randomart image is:......
查看主目录里.ssh文件夹,发现多了id_ecdsa和id_ecdsa.pub。
3、GitHub设置。登陆GitHub,点击setting,配置SSH and GPG keys。点击New SSH Key,输入自定义title值,比如ECDSA;然后再key值里输入文件id_ecdsa.pub的内容。
4、Eclipse配置。从Eclipse窗口菜单Window -> preferences ->general ->Network Connection -> SSH2,在弹出窗口的general标签页,点击Add Private Key...,添加主目录里.ssh文件的id_ecdsa。点击Apply and Close。测试Commit and Push,仍然失败,错误信息一如本文开头所述。一气之下,再次从Eclipse窗口菜单Window -> preferences ->general ->Network Connection -> SSH2,来到弹出窗口的general标签页,把Private Keys框中排在id_ecdsa之前的id_rsa、id_dsa删除,只留下id_ecdsa。Apply and Close,测试成功,在Eclipse平台上写的教学示例脚本终于又能一键推送到GitHub了
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-22 04:14
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社