Today, I am helping a customer deploy a new server, thinking about using the new one instead of the old one, so I used the CentOS Stream 9 system.
For security, log in without a password, just use the automatically generated SSH key on Tencent Cloud.
The first thing to do when entering the system is of course to update a wave of pre-installed software.
My ssh can't connect to the server!
Restart the server, restart finalshell, to no avail.
Checked the log:
cat /var/log/secure
Found this error:
userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
Baidu can't figure it out, so use Google.
Knowing that it should be caused by the new version of openssh, adding several configuration items mentioned by foreign netizens will not work after restarting sshd.
So we can only resort to the ultimate solution - regenerate the key that can be used
ssh-keygen -t ecdsa
After generating, import Tencent Cloud's SSH key (file in: ~/.ssh)
At this time, the problem comes again, finalshell prompts:
暂不支持此私钥格式,请参考以下方法解决:
1.转换成PEM格式私钥
ssh-keygen -p -m PEM -f 私钥路径
2.生成PEM格式的私钥
生成时增加 -m PEM参数
ssh-keygen -m PEM -t rsa -C "注释"
So I used this to convert the private key (note that the original file will be overwritten, backup first if necessary)
ssh-keygen -p -m PEM -f id_ecdsa
Import the converted private key with finalshell and successfully connect to the server!
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。