jsch JSchAlgoNegoFailException 算法协商失败

问题描述 投票:0回答:1

使用jsch-0.2.17.jar

我可以使用 WINSCP 连接,但不能使用 jsch

我正在设置这些属性: config.put("StrictHostKeyChecking", "否"); config.put("PubkeyAcceptedAlgorithms", "ssh-rsa");

出现此错误:

com.jcraft.jsch.JSchAlgoNegoFailException: Algorithm negotiation fail: algorithmName="server_host_key" jschProposal="ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256" serverProposal="ssh-rsa"

设置此配置

日志:

INFO: Connecting to HOSTNAME port 22
INFO: Connection established
INFO: Remote version string: SSH-2.0-_ SFTP
INFO: Local version string: SSH-2.0-JSCH_0.2.17
INFO: CheckCiphers: [email protected]
INFO: CheckKexes: [email protected],curve25519-sha256,[email protected],curve448-sha512
INFO: [email protected] is not available.
INFO: curve25519-sha256 is not available.
INFO: [email protected] is not available.
INFO: curve448-sha512 is not available.
DEBUG: kex proposal before removing unavailable algos is: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256
DEBUG: kex proposal after removing unavailable algos is: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256
INFO: CheckSignatures: ssh-ed25519,ssh-ed448
INFO: ssh-ed25519 is not available.
INFO: ssh-ed448 is not available.
DEBUG: server_host_key proposal before removing unavailable algos is: ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256
DEBUG: server_host_key proposal after removing unavailable algos is: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256
DEBUG: server_host_key proposal before known_host reordering is: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256
DEBUG: server_host_key proposal after known_host reordering is: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256
INFO: SSH_MSG_KEXINIT sent
INFO: SSH_MSG_KEXINIT received
INFO: server proposal: KEX algorithms: ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group18-sha512,diffie-hellman-group16-sha512,diffie-hellman-group14-sha256,diffie-hellman-group-exchange-sha256
INFO: server proposal: host key algorithms: ssh-rsa
INFO: server proposal: ciphers c2s: [email protected],aes256-ctr,[email protected],aes192-ctr,[email protected],aes128-ctr
INFO: server proposal: ciphers s2c: [email protected],aes256-ctr,[email protected],aes192-ctr,[email protected],aes128-ctr
INFO: server proposal: MACs c2s: [email protected],hmac-sha2-512,[email protected],hmac-sha2-256
INFO: server proposal: MACs s2c: [email protected],hmac-sha2-512,[email protected],hmac-sha2-256
INFO: server proposal: compression c2s: zlib,none
INFO: server proposal: compression s2c: zlib,none
INFO: server proposal: languages c2s: 
INFO: server proposal: languages s2c: 
INFO: client proposal: KEX algorithms: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c,[email protected]
INFO: client proposal: host key algorithms: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256
INFO: client proposal: ciphers c2s: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
INFO: client proposal: ciphers s2c: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
INFO: client proposal: MACs c2s: [email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
INFO: client proposal: MACs s2c: [email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
INFO: client proposal: compression c2s: none
INFO: client proposal: compression s2c: none
INFO: client proposal: languages c2s: 
INFO: client proposal: languages s2c: 
INFO: Disconnecting from HOSTNAME port 22
com.jcraft.jsch.JSchAlgoNegoFailException: Algorithm negotiation fail: algorithmName="server_host_key" jschProposal="ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256" serverProposal="ssh-rsa"

感谢任何帮助?

jsch
1个回答
0
投票

您必须配置 jsch 以接受不安全的服务器配置,如常见问题解答中所述 https://github.com/mwiede/jsch?tab=readme-ov-file#why-do-ssh-rsa-type-keys-不与此 jsch-fork-and-my-server 一起工作

例如

JSch.setConfig("server_host_key", JSch.getConfig("server_host_key") + ",ssh-rsa");
JSch.setConfig("PubkeyAcceptedAlgorithms", JSch.getConfig("PubkeyAcceptedAlgorithms") + ",ssh-rsa")
© www.soinside.com 2019 - 2024. All rights reserved.