SSH 连接是否需要使用 Public Key 以及 authorized_keys

global_biz 2014-10-12 06:44:47
Hi,

在用 SSH 连接一台 Linux 服务器 OpenSSH 的时候,出现错误,
1939 [main] DEBUG com.sshtools.j2ssh.transport.publickey.SshKeyPairFactory - The default public key is not set! using first in list.
从上面提示来看,好像是要在连接的时候提供 Public Key ?

这些连接所需的 key 在同一个目录下, private key 的文件名是 id_dsa, public key 对应的文件名是 id_dsa.pub,
还有一个 authorized_keys 不知是什么用,

现在尝试连接的时候,只使用到了一个 id_dsa 的文件,其他文件没用上,
请大家帮下忙看下,是不是还有什么需要设置?

下面是输出结果,供参考:

481 [main] INFO com.sshtools.j2ssh.transport.cipher.SshCipherFactory - Loading supported cipher algorithms
1307 [main] INFO com.sshtools.j2ssh.transport.kex.SshKeyExchangeFactory - Loading key exchange methods
1335 [main] INFO com.sshtools.j2ssh.configuration.ConfigurationLoader - JAVA version is 1.6.0_22
1339 [main] INFO com.sshtools.j2ssh.configuration.ConfigurationLoader - Extension C:\Program Files (x86)\Java\jdk1.6.0_22\jre\lib\ext\dnsns.jar being added to classpath
1356 [main] INFO com.sshtools.j2ssh.util.ExtensionClassLoader - Adding C:\Program Files (x86)\Java\jdk1.6.0_22\jre\lib\ext\dnsns.jar to the extension classpath
1356 [main] INFO com.sshtools.j2ssh.configuration.ConfigurationLoader - Extension C:\Program Files (x86)\Java\jdk1.6.0_22\jre\lib\ext\localedata.jar being added to classpath
1365 [main] INFO com.sshtools.j2ssh.util.ExtensionClassLoader - Adding C:\Program Files (x86)\Java\jdk1.6.0_22\jre\lib\ext\localedata.jar to the extension classpath
1365 [main] INFO com.sshtools.j2ssh.configuration.ConfigurationLoader - Extension C:\Program Files (x86)\Java\jdk1.6.0_22\jre\lib\ext\sunjce_provider.jar being added to classpath
1388 [main] INFO com.sshtools.j2ssh.util.ExtensionClassLoader - Adding C:\Program Files (x86)\Java\jdk1.6.0_22\jre\lib\ext\sunjce_provider.jar to the extension classpath
1388 [main] INFO com.sshtools.j2ssh.configuration.ConfigurationLoader - Extension C:\Program Files (x86)\Java\jdk1.6.0_22\jre\lib\ext\sunmscapi.jar being added to classpath
1413 [main] INFO com.sshtools.j2ssh.util.ExtensionClassLoader - Adding C:\Program Files (x86)\Java\jdk1.6.0_22\jre\lib\ext\sunmscapi.jar to the extension classpath
1413 [main] INFO com.sshtools.j2ssh.configuration.ConfigurationLoader - Extension C:\Program Files (x86)\Java\jdk1.6.0_22\jre\lib\ext\sunpkcs11.jar being added to classpath
1435 [main] INFO com.sshtools.j2ssh.util.ExtensionClassLoader - Adding C:\Program Files (x86)\Java\jdk1.6.0_22\jre\lib\ext\sunpkcs11.jar to the extension classpath
1435 [main] DEBUG com.sshtools.j2ssh.transport.kex.SshKeyExchangeFactory - The default key exchange is not set! using first in list
1439 [main] INFO com.sshtools.j2ssh.transport.publickey.SshKeyPairFactory - Loading public key algorithms
1464 [main] DEBUG com.sshtools.j2ssh.transport.publickey.SshKeyPairFactory - The default public key is not set! using first in list
1466 [main] INFO com.sshtools.j2ssh.transport.compression.SshCompressionFactory - Loading compression methods
1477 [main] INFO com.sshtools.j2ssh.transport.hmac.SshHmacFactory - Loading message authentication methods
1665 [main] INFO com.sshtools.j2ssh.transport.TransportProtocolCommon - Starting transport protocol
1670 [Transport protocol 1] INFO com.sshtools.j2ssh.transport.TransportProtocolCommon - Registering transport protocol messages with inputstream
3113 [Transport protocol 1] INFO com.sshtools.j2ssh.transport.TransportProtocolCommon - Negotiating protocol version
3113 [Transport protocol 1] DEBUG com.sshtools.j2ssh.transport.TransportProtocolCommon - Local identification: SSH-2.0-http://www.sshtools.com J2SSH [CLIENT]
3114 [Transport protocol 1] DEBUG com.sshtools.j2ssh.transport.TransportProtocolCommon - EOL is guessed at LF
3114 [Transport protocol 1] DEBUG com.sshtools.j2ssh.transport.TransportProtocolCommon - Remote identification: SSH-2.0-OpenSSH_4.3
3114 [Transport protocol 1] INFO com.sshtools.j2ssh.transport.TransportProtocolCommon - Protocol negotiation complete
3115 [Transport protocol 1] DEBUG com.sshtools.j2ssh.transport.TransportProtocolCommon - SshMsgKexInit:
Supported Kex [diffie-hellman-group1-sha1]
Supported Public Keys [ssh-rsa, ssh-dss]
Supported Encryption Client->Server [blowfish-cbc, 3des-cbc]
Supported Encryption Server->Client [blowfish-cbc, 3des-cbc]
Supported Mac Client->Server [hmac-sha1, hmac-md5-96, hmac-sha1-96, hmac-md5]
Supported Mac Server->Client [hmac-sha1, hmac-md5-96, hmac-sha1-96, hmac-md5]
Supported Compression Client->Server [none]
Supported Compression Server->Client [none]
Supported Languages Client->Server []
Supported Languages Server->Client []
First Kex Packet Follows [FALSE]
3115 [Transport protocol 1] INFO com.sshtools.j2ssh.transport.TransportProtocolCommon - Sending SSH_MSG_KEX_INIT
3139 [Transport protocol 1] ERROR com.sshtools.j2ssh.transport.TransportProtocolCommon - The Transport Protocol thread failed
com.sshtools.j2ssh.transport.TransportProtocolException: IO Error on socket: Software caused connection abort: socket write error
at com.sshtools.j2ssh.transport.TransportProtocolOutputStream.sendMessage(Unknown Source)
at com.sshtools.j2ssh.transport.TransportProtocolCommon.sendMessage(Unknown Source)
at com.sshtools.j2ssh.transport.TransportProtocolCommon.sendKeyExchangeInit(Unknown Source)
at com.sshtools.j2ssh.transport.TransportProtocolCommon.startBinaryPacketProtocol(Unknown Source)
at com.sshtools.j2ssh.transport.TransportProtocolCommon.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
3162 [Transport protocol 1] DEBUG com.sshtools.j2ssh.transport.TransportProtocolCommon - The Transport Protocol has been stopped


谢谢。
...全文
1327 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qingyuan18 2014-10-13
  • 打赏
  • 举报
回复
id_dsa/ id_dsa.pub:你用openssh工具生成的私钥公钥对 authorized_keys :你使用ssh连接的linux服务器需要认证你的身份,所以你需要在连接的linux服务器上安装自已的公钥,authorized_keys这里面就是存放你自己的id_dsa.pub的内容 当然ssh也可以配置为不使用RSA公钥密钥认证而使用传统用户密码,这样你用ssh连linux的时候会弹出用户密码的提示输入,具体参见etc/ssh/下配置文件中的PasswordAuthentication yes AllowedAuthentications password 来开启,不过你是用程序模拟ssh登录过程,所以还是配置好公钥密钥才是正确方式 注意你的服务器的ssh版本,ssh v2的版本才是 authorized_keys的认证文件,可以通过用户目录~/.ssh2/authorized_keys来识别 java连ssh的开源包gamay-openssh比较常用
Glory_Nol 2014-10-13
  • 打赏
  • 举报
回复
好像服務器設置了那就需要,不設置就不需要。

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧