Open kirandasika0 opened 1 year ago
HI @kirandasika30,
The server does not appear to recognize your SSH key so it authentication fails. You should confirm that your SSH key is correctly added to the authorized_keys file for the user account on the server.
Thanks, Jeremy
Hi @norrisjeremy,
Thank you for getting back. I've double checked that the key was added to server properly. The issue stems from the fact that the server disabled the use of ssh-rsa signature algorithm. But, the server only accepts public key types prefixed with ssh-rsa
. I tried adding the ssh-rsa
key type as one of the PubkeyAcceptedAlgorithms
but it still seems to show the same error.
Hi @kirandasika30,
I'm not sure what other assistance I can provide: the log messages you provided indicate the server has rejected your SSH key, so it either isn't correctly added on the server or the server has disabled the use of the rsa-sha2-512 & rsa-sha2-256 signature algorithms. Perhaps you can try to investigate log messages on the server end to better understand why this failure is occurring?
Thanks, Jeremy
Hi, I was able get some logs from the server. But, they don't point to any obvious error.
com.jcraft.jsch.JSchException: Auth fail for methods 'publickey' [preauth]
Any idea why this exception might be triggered?
Hi @kirandasika30,
All I can state is based upon the information that you have provided, the server has rejected your SSH key. This would lead me to conclude that your key is not actually properly added on the server for the user account which you are attempting to use.
Thanks, Jeremy
Hi @norrisjeremy ,
Thanks for getting back. The ssh-rsa
key type was deprecated causing the error. Unfortunately, I don't have much control over the server side to provide you any logs.
Have you seen this scenario play out where the library has issues in containers specifically Azul JDK but work normally when running on a regular VM?
Hi @kirandasika30,
I don't know why you would be having issues with your containers. All I can state is the log messages you have provided indicate indicate the server is not accepting your public key, which would seem to indicate that the key has not been added for the user account which you are attempting to use.
Thanks, Jeremy
You can use this solution:
add the remote IP address or hostname into the ~/.ssh/known_hosts
ssh-keyscan -t rsa <HOST_NAME> >> ~/.ssh/known_hosts
ssh-keyscan -t rsa <IP_ADDRESS_OF_HOST_NAME> >> ~/.ssh/known_hosts
load file known_hosts
jsch.setKnownHosts(new FileInputStream(knowHosts));
get session and add PreferredAuthentications
Session jschSession = jsch.getSession(username, remoteHost, port);
jschSession.setConfig("PreferredAuthentications", "publickey");
add identity
jsch.addIdentity(pathPrivateKey, passphrase);
add configuration to set algo rsa
Properties config = new Properties();
config.put("PubkeyAcceptedKeyTypes", "ssh-rsa");
config.put("HostKeyAlgorithms", "ssh-rsa");
jschSession.setConfig(config);
add session timeout and open channel
jschSession.connect(SESSION_TIMEOUT);
ChannelSftp channel = (ChannelSftp) jschSession.openChannel("sftp");
Hi, I'm running into this issue when trying to establish an SSH connection to my server. Can someone explain why this seems to be in jsch 0.2.11?
How I build my identity:
Logs: