Java 崩溃外壳程序无法通过ssh连接

Java 崩溃外壳程序无法通过ssh连接,java,tomcat,ssh,Java,Tomcat,Ssh,我有一个嵌入shell库的独立Tomcat应用程序。 我可以通过telnet成功地连接到应用程序,但我正在努力使用ssh 以下是我的crash.properties配置: # Key authentication crash.auth=key crash.auth.key.path=/usr/share/tomcat8/conf/id_rsa.pem # SSH configuration crash.ssh.port=2000 我通过ssh-keygen生成了一个ssh密钥对,然后通过op

我有一个嵌入shell库的独立Tomcat应用程序。 我可以通过telnet成功地连接到应用程序,但我正在努力使用ssh

以下是我的crash.properties配置:

# Key authentication
crash.auth=key
crash.auth.key.path=/usr/share/tomcat8/conf/id_rsa.pem

# SSH configuration
crash.ssh.port=2000
我通过ssh-keygen生成了一个ssh密钥对,然后通过openssl rsa-in-id\u rsa-outform pem-pubout>id\u rsa.pem命令创建了一个pem文件

无论使用何种ssh密钥,当我尝试通过ssh-I/usr/share/tomcat8/conf/id\u rsa-p 2000 myserver.example.com命令进行连接时都会出现错误:

Permission denied (publickey).
我尝试过所描述的解决方案,但没有成功。我还尝试将id_rsa.pem密钥放入war/WEB-INF/sshd文件夹中。同样的结果


有什么线索吗?

调试后,我注意到org.crsh.auth.keyeauthenticationplugin正在比较授权密钥和登录时提供的密钥,它们是相同的,但方法authenticate总是返回假错误的身份验证。修复错误后,我意识到它已经被声明了,而且一个拉请求也可用。

您可能还需要给ssh命令一个端口号。SSH默认为22,所以您需要告诉它使用端口2000。尝试ssh-i/path/to/private/key myserver.example.com:2000抱歉忘了在我的ssh命令中提到它:我使用-p 2000和相同的结果。假设您还没有实现这一点,在命令行中添加-v参数时尝试启用详细模式的ssh可能会有所帮助,这样您就可以获得有关它认为不起作用的原因的更多信息。