You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been using a generic code to create Connection with different data providers but due to key exchange alogirthms limitations for vendor 1 i had to deploy the jsch-0.2.20 jar within the application. Post deployment the Algorithm Negotation Failed was resolved for that data vendor 1 but one perfectly working connection (data vendor 2) is facing failure now. I was facing Algorithm Negotation Failed for ssh-rsa host key that was resolved appending the same in session.config but now i am facing java.net.ConnectException: Connection timed out.
(Also with backporting to older jsch version the connection starts working fine with data-vendor2 again.)
The code base is as below along with some important info logger statements revealing the issue is occuring just at session.connect().
Code:
public void connect(String hostName, int port, String user, String passWord) throws RBException {
System.out.println("Accessing the connect method");
logger.info("Trying to log in on server " + hostName + " as user " + user);
logger.info("Entered method 1 of connect");
JschSFTP loge = new JschSFTP();
JSch.setLogger(loge);
logger.info("Trying to log in on server " + hostName + " as user " + user);
this.hostName = hostName;
this.user = user;
this.passWord = passWord;
JSch jSch = new JSch();
try {
session = jSch.getSession(user, hostName, port);
logger.info("Block 1 user,Hostname and port are : "+user+", "+hostName+", "+port);
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.setTimeout(timeOut * 1000);
session.setPassword(passWord);
session.connect();
channel = session.openChannel("sftp");
sftp = (ChannelSftp) channel;
sftp.connect();
loggedIn = true;
logger.error("User " + user + " successfully logged in on server " + hostName);
cwd = sftp.pwd();
} catch (JSchException e) {
try {
logger.info("Entered catch of method 1");
logger.info("The error message in catch 1 is : "+e.getMessage());
if (e.getMessage().contains("java.security.InvalidAlgorithmParameterException")||e.getMessage().contains("Algorithm negotiation fail")) {
session.disconnect();
Security.insertProviderAt(new BouncyCastleProvider(), 1);
if(proxyHost==null || proxyHost.isEmpty()) {
proxyPort=0;
}
session = getSession(jSch, hostName, user, passWord, 22, proxyHost, proxyPort);
logger.info("Session setup done");
logger.info("Session config after appending for host key : "+(session.getConfig("server_host_key")));
logger.info("Session timeout is in : "+session.getTimeout());
session.connect();
if(session!=null) {
logger.info("Session established via catch 1");
}
channel = session.openChannel("sftp");
if(channel!=null) {
logger.info("Channel established via catch 1");
}
sftp = (ChannelSftp) channel;
sftp.connect();
if(sftp!=null) {
logger.info("sftp established via catch 1");
}
loggedIn = true;
logger.error("User " + user + " successfully logged in on server " + hostName);
cwd = sftp.pwd();
} else {
logger.info("Entered else block of catch 1");
loggedIn = false;
logger.fatal("User " + user + " failed to log in on server " + hostName);
throw new RBException(com.j2fe.ra.fileSystem.ftp.FTP.class, 1003L, e);
}
} catch (JSchException ex) {
logger.info("Entered JSCHException of block 1");
logger.info("The exception from jsch block is "+ex.getMessage());
loggedIn = false;
logger.fatal("User " + user + " failed to log in on server " + hostName);
throw new RBException(com.j2fe.ra.fileSystem.ftp.FTP.class, 1003L, ex);
}
catch (SftpException ex) {
logger.info("Entered SFTPException of block 1");
throw new RBException(com.j2fe.ra.fileSystem.ftp.FTP.class, 1020L, ex);
} catch (SecurityException ex) {
logger.fatal(ex);
throw new RBException(com.j2fe.ra.fileSystem.ftp.FTP.class, 1020L, ex);
}
} catch (SftpException e) {
throw new RBException(com.j2fe.ra.fileSystem.ftp.FTP.class, 1020L, e);
} catch (SecurityException e) {
logger.fatal(e);
throw new RBException(com.j2fe.ra.fileSystem.ftp.FTP.class, 1020L, e);
}
}
public static Session getSession(JSch jsch, String host, String user, String password, int port, String proxyHost,
int proxyPort) throws JSchException {
Session session = jsch.getSession(user, host, port);
java.util.Properties config = new java.util.Properties();
logger.info("Session config for host key : "+(session.getConfig("server_host_key")));
config.put("server_host_key", "ssh-rsa,"+session.getConfig("server_host_key"));
logger.info("Session config after appending for host key : "+(config.get("server_host_key")));
config.put("StrictHostKeyChecking", "no");
config.put("PreferredAuthentications", "publickey,keyboard-interactive,password");
session.setConfig(config);
session.setTimeout(1800*1000);
if (proxyHost != null) {
session.setProxy(new ProxySOCKS5(proxyHost, proxyPort));
}
if (password != null) {
session.setPassword(password);
}
return session;
}
And the logs are:
Retry # 2 of method connect necessary. Problem: ERROR: Failed to login to (S)FTP Server.
Error occoured during reconnect to FTP server
Trying to log in
Entered method 1 of connect
Trying to log in on server
Block 1 user,Hostname and port are *********************************************
Entered catch of method 1
The error message in catch 1 is : Algorithm negotiation fail: algorithmName="server_host_key" jschProposal="ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256" serverProposal="ssh-rsa,ssh-dss"
Session config for host key : ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256
Session config after appending for host key : ssh-rsa,ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256
Session setup done
Session config after appending for host key : ssh-rsa,ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256
Session timeout is in : 1800000
Entered JSCHException of block 1
The exception from jsch block is java.net.ConnectException: Connection timed out
Kindly guide why after deploying this version i am facing this error but still after backporting the jsch jar to older version it again starts working fine.
The text was updated successfully, but these errors were encountered:
I have been using a generic code to create Connection with different data providers but due to key exchange alogirthms limitations for vendor 1 i had to deploy the jsch-0.2.20 jar within the application. Post deployment the Algorithm Negotation Failed was resolved for that data vendor 1 but one perfectly working connection (data vendor 2) is facing failure now. I was facing Algorithm Negotation Failed for ssh-rsa host key that was resolved appending the same in session.config but now i am facing java.net.ConnectException: Connection timed out.
(Also with backporting to older jsch version the connection starts working fine with data-vendor2 again.)
The code base is as below along with some important info logger statements revealing the issue is occuring just at session.connect().
Code:
public void connect(String hostName, int port, String user, String passWord) throws RBException {
System.out.println("Accessing the connect method");
logger.info("Trying to log in on server " + hostName + " as user " + user);
logger.info("Entered method 1 of connect");
}
public static Session getSession(JSch jsch, String host, String user, String password, int port, String proxyHost,
int proxyPort) throws JSchException {
}
And the logs are:
Retry # 2 of method connect necessary. Problem: ERROR: Failed to login to (S)FTP Server.
Error occoured during reconnect to FTP server
Trying to log in
Entered method 1 of connect
Trying to log in on server
Block 1 user,Hostname and port are *********************************************
Entered catch of method 1
The error message in catch 1 is : Algorithm negotiation fail: algorithmName="server_host_key" jschProposal="ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256" serverProposal="ssh-rsa,ssh-dss"
Session config for host key : ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256
Session config after appending for host key : ssh-rsa,ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256
Session setup done
Session config after appending for host key : ssh-rsa,ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256
Session timeout is in : 1800000
Entered JSCHException of block 1
The exception from jsch block is java.net.ConnectException: Connection timed out
Kindly guide why after deploying this version i am facing this error but still after backporting the jsch jar to older version it again starts working fine.
The text was updated successfully, but these errors were encountered: