sohutv / cachecloud

搜狐视频(sohu tv)Redis私有云平台 :支持Redis多种架构(Standalone、Sentinel、Cluster)高效管理、有效降低大规模redis运维成本,提升资源管控能力和利用率。平台提供快速搭建/迁移,运维管理,弹性伸缩,统计监控,客户端整合接入等功能。(CacheCloud is a Redis cloud management platform. It supports Standalone, Sentinel, and Cluster architectures for Redis, effectively reducing large-scale Redis operation and maintenance costs, and improving resource management and utilization. The platform provides rapid construction/migration, operation and maintenance management, elastic scaling, statistical monitoring, client integration and access and other functions)
http://cachecloud.github.io/
Apache License 2.0
8.89k stars 2.04k forks source link

按照文档配置了ssh秘钥,手动登录都没问题,但是日志报错Publickey authentication failed. #301

Closed qiqiaobin closed 1 year ago

qiqiaobin commented 1 year ago

2023-03-03 12:21:01.011 WARN 14645 --- [-pool-thread-63] c.s.c.machine.impl.MachineCenterImpl : machine stats is null, ip: 10.77.110.60, time: Fri Mar 03 12:21:01 CST 2023 2023-03-03 12:21:01.013 WARN 14645 --- [-pool-thread-65] c.s.c.machine.impl.MachineCenterImpl : machine stats is null, ip: 10.77.110.57, time: Fri Mar 03 12:21:01 CST 2023 2023-03-03 12:21:01.015 WARN 14645 --- [-pool-thread-67] c.s.c.machine.impl.MachineCenterImpl : machine stats is null, ip: 10.77.110.58, time: Fri Mar 03 12:21:01 CST 2023 2023-03-03 12:21:01.016 WARN 14645 --- [-pool-thread-71] c.s.c.machine.impl.MachineCenterImpl : machine stats is null, ip: 10.77.110.62, time: Fri Mar 03 12:21:01 CST 2023 2023-03-03 12:21:01.018 WARN 14645 --- [-pool-thread-74] c.s.c.machine.impl.MachineCenterImpl : machine stats is null, ip: 10.77.110.61, time: Fri Mar 03 12:21:01 CST 2023 2023-03-03 12:21:01.019 WARN 14645 --- [-pool-thread-76] c.s.c.machine.impl.MachineCenterImpl : machine stats is null, ip: 10.77.110.59, time: Fri Mar 03 12:21:01 CST 2023 2023-03-03 12:21:01.087 ERROR 14645 --- [-pool-thread-68] com.sohu.cache.ssh.SSHTemplate : getConnection 10.77.110.57:22 error message is Publickey authentication failed.

java.io.IOException: Publickey authentication failed. at ch.ethz.ssh2.auth.AuthenticationManager.authenticatePublicKey(AuthenticationManager.java:259) at ch.ethz.ssh2.Connection.authenticateWithPublicKey(Connection.java:377) at ch.ethz.ssh2.Connection.authenticateWithPublicKey(Connection.java:428) at com.sohu.cache.ssh.SSHTemplate$1.execute(SSHTemplate.java:107) at com.sohu.cache.util.IdempotentConfirmer.run(IdempotentConfirmer.java:27) at com.sohu.cache.ssh.SSHTemplate.getConnection(SSHTemplate.java:122) at com.sohu.cache.ssh.SSHTemplate.execute(SSHTemplate.java:50) at com.sohu.cache.ssh.SSHTemplate.execute(SSHTemplate.java:33) at com.sohu.cache.server.ServerStatusCollector.fetchServerStatus(ServerStatusCollector.java:77) at com.sohu.cache.server.ServerStatusCollector$1.execute(ServerStatusCollector.java:60) at com.sohu.cache.server.ServerStatusCollector$1.execute(ServerStatusCollector.java:57) at com.sohu.cache.async.KeyCallable.call(KeyCallable.java:22) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.io.IOException: Invalid PEM structure, '-----BEGIN...' missing at ch.ethz.ssh2.crypto.PEMDecoder.parsePEM(PEMDecoder.java:137) at ch.ethz.ssh2.crypto.PEMDecoder.decode(PEMDecoder.java:312) at ch.ethz.ssh2.auth.AuthenticationManager.authenticatePublicKey(AuthenticationManager.java:168) ... 15 common frames omitted

2023-03-03 12:21:01.089 WARN 14645 --- [-pool-thread-68] com.sohu.cache.ssh.SSHTemplate : connect 10.77.110.57:22 timeOutFactor is 2 2023-03-03 12:21:01.090 ERROR 14645 --- [-pool-thread-68] com.sohu.cache.ssh.SSHTemplate : getConnection 10.77.110.57:22 error message is Connection to 10.77.110.57 is already in connected state!

java.io.IOException: Connection to 10.77.110.57 is already in connected state! at ch.ethz.ssh2.Connection.connect(Connection.java:585) at com.sohu.cache.ssh.SSHTemplate$1.execute(SSHTemplate.java:102) at com.sohu.cache.util.IdempotentConfirmer.run(IdempotentConfirmer.java:27) at com.sohu.cache.ssh.SSHTemplate.getConnection(SSHTemplate.java:122) at com.sohu.cache.ssh.SSHTemplate.execute(SSHTemplate.java:50) at com.sohu.cache.ssh.SSHTemplate.execute(SSHTemplate.java:33) at com.sohu.cache.server.ServerStatusCollector.fetchServerStatus(ServerStatusCollector.java:77) at com.sohu.cache.server.ServerStatusCollector$1.execute(ServerStatusCollector.java:60) at com.sohu.cache.server.ServerStatusCollector$1.execute(ServerStatusCollector.java:57) at com.sohu.cache.async.KeyCallable.call(KeyCallable.java:22) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

2023-03-03 12:21:01.090 WARN 14645 --- [-pool-thread-68] com.sohu.cache.ssh.SSHTemplate : connect 10.77.110.57:22 timeOutFactor is 3 2023-03-03 12:21:01.090 ERROR 14645 --- [-pool-thread-68] com.sohu.cache.ssh.SSHTemplate : getConnection 10.77.110.57:22 error message is Connection to 10.77.110.57 is already in connected state!

java.io.IOException: Connection to 10.77.110.57 is already in connected state! at ch.ethz.ssh2.Connection.connect(Connection.java:585) at com.sohu.cache.ssh.SSHTemplate$1.execute(SSHTemplate.java:102) at com.sohu.cache.util.IdempotentConfirmer.run(IdempotentConfirmer.java:27) at com.sohu.cache.ssh.SSHTemplate.getConnection(SSHTemplate.java:122) at com.sohu.cache.ssh.SSHTemplate.execute(SSHTemplate.java:50) at com.sohu.cache.ssh.SSHTemplate.execute(SSHTemplate.java:33) at com.sohu.cache.server.ServerStatusCollector.fetchServerStatus(ServerStatusCollector.java:77) at com.sohu.cache.server.ServerStatusCollector$1.execute(ServerStatusCollector.java:60) at com.sohu.cache.server.ServerStatusCollector$1.execute(ServerStatusCollector.java:57) at com.sohu.cache.async.KeyCallable.call(KeyCallable.java:22) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

cacheCloud-WEB 版本3.2 ssh文件权限按照文档配置,authorized_keys 是755权限 id_rsa是600权限

githubname1024 commented 1 year ago

请确认一下配置的key是否是private key,还是误配置成了public key。 如不是,请提供cachecloud 部署机器的系统版本。

qiqiaobin commented 1 year ago

图片 [root@ops-JFSRedisCloudWeb-1 ~]# uname -a Linux ops-JFSRedisCloudWeb-1 5.4.185-200.el7.x86_64 #1 SMP Thu Mar 31 14:48:33 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux [root@ops-JFSRedisCloudWeb-1 ~]# cat /etc/centos-release CentOS Linux release 7.9.2009 (Core)

我的JDK用的是1.8版本的

githubname1024 commented 1 year ago

确认密钥串是没有问题吗,密钥串与你通过ssh访问机器时的密钥串是一致的吗?你的回复中没有提到。 也可以自行搜索一下产生这个错误的原因,Caused by: java.io.IOException: Invalid PEM structure, '-----BEGIN...' missing 这个应该是密钥配置错误,或者机器层面的问题。如有问题,可以追加comment。

qiqiaobin commented 1 year ago

问题已解决,使用命令 ssh-keygen -t rsa 生成ssh密钥,默认是以新的格式生成,需要使用 -m 参数指定密钥的格式为PEM(也就是RSA格式)是之前使用的旧格式 ,新的命令 ssh-keygen -m PEM -t rsa -b 4096 来生成