mwiede / jsch

fork of the popular jsch library
Other
767 stars 144 forks source link

java.lang.ArrayIndexOutOfBoundsException with jsch version 0.2.18 #591

Closed swathimr closed 3 months ago

swathimr commented 4 months ago

I am using JSCH to connect to SFTP with high traffic and recently updated the library from com.jcraft. We saw this error recently and in local environment I am not able to reproduce the issue.

Screenshot 2024-07-09 at 4 03 24 PM

Screenshot 2024-07-09 at 4 06 56 PM Can you please let me know whats causing this ?

norrisjeremy commented 4 months ago

You have a bug in your code. The lines where you are calling JSch.setConfig("server_host_key", ...) and JSch.setConfig("PubkeyAcceptedAlgorithms", ...), you are constantly appending ,ssh-rsa,ssh-dss over and over to them every time you call your getConnection() method.

swathimr commented 4 months ago

I followed this listed here https://github.com/mwiede/jsch?tab=readme-ov-file#why-do-ssh-rsa-type-keys-not-work-with-this-jsch-fork-and-my-server

norrisjeremy commented 4 months ago

JSch.setConfig() are static methods that act on global static state. If you need to change this on a per-session basis, then you should use session.setConfig(), so that it doesn't constantly change global static state.

swathimr commented 4 months ago

okay I will try that. Does this issue occur only with the heavy load or multiple connects ?

norrisjeremy commented 4 months ago

Hi @swathimr,

This has nothing to do with heavy load or multiple connects: your code is simply flawed.

Thanks, Jeremy