~/.ssh/config 文件:
Host ftp.myhome.io
IdentityFile ~/.ssh/id_rsa_myhome
User ubuntu
~/.ssh/id_rsa_myhome 私钥文件:
...此处省略...
请问腾讯云这个ssh公钥到底存在什么地方呢?
我用 grep 搜索 /etc 目录, 发现没有找到.
99元的腾讯云在这里: https://whycan.cn/t_3334.html#p34613
离线
发现一个更诡异的问题, 一台以前买的腾讯云 即使用密钥, 也另外要密码才能登录,
ssh客户端日志是这样的:
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /c/Users/Administrator/.ssh/id_rsa.myhome
debug1: Authentications that can continue: publickey,password
还是要提示输入密码.
另外一台只要密钥配对就可以了.
ssh客户端日志是这样的:
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /c/Users/Administrator/.ssh/id_rsa.myhome
debug1: Authentication succeeded (publickey).
然后就可以到控制台了
离线
~/.ssh/目录下
离线
~/.ssh/目录下
在腾讯云提交了工单, 他们给我的方案是:
您好,
若您这边只需要密钥登录,而不需要密码登录,请您在配置文件中修改禁止密码登录即可。
编辑/etc/ssh/sshd_config
将
PasswordAuthentication参数值修改为no:
PasswordAuthentication no重启ssh服务:systemctl restart sshd.service
然后我一直改的是 /etc/ssh/ssh_config
死活么反应, 然后腾讯云工程师还打电话过来沟通,
工单提交 密码之后, 点授权按钮, 他们工程师帮我进系统修改好了.
现在用密钥登录一切 OK
离线
看来腾讯云还不太成熟,估计坑不少
离线
看来腾讯云还不太成熟,估计坑不少
有没有坑不知道, 但是这个是我自己的锅, 我改错配置文件了.
离线
终于搞明白了, 公钥就是服务器的 ~/.ssh/authorized_keys 文件
腾讯云默认用户是 ubuntu,
所以真实路径是:
/home/ubuntu/.ssh/authorized_keys
我一直自以为是在 /etc 目录
离线
如果是同一个用户(ubuntu)提交多个私钥文件, 那么私钥是怎么存储呢?是多个密钥文件?还是全部存储在 ~/.ssh/authorized_keys?
离线
感谢分享, 我也顺手总结了一下: 分享一个 ssh 服务器强制密钥登录, 阿里云/腾讯云/bwh/vultr 的 Linux 服务器都适用。
离线