Issue
Configured Node:
Launch method: Launchagents via SSH
Host: host
Credentials: added a new one by specifying username and Private key
Host Key Verification Strategy: Not verifying (The error does not differ when choosing a different value)
When I try to connect, I get an error:
[08/24/22 14:39:14] [SSH] Opening SSH connection to host:22.
[08/24/22 14:39:14] [SSH] WARNING: SSH Host Keys are not being verified. Man-in-the-middle attacks may be possible against this connection.
ERROR: Server rejected the 1 private key(s) for cred_name (credentialId:cred_name/method:publickey)
ERROR: Failed to authenticate as cred_name with credential=cred_name
java.io.IOException: Publickey authentication failed.
at com.trilead.ssh2.auth.AuthenticationManager.authenticatePublicKey(AuthenticationManager.java:349)
at com.trilead.ssh2.Connection.authenticateWithPublicKey(Connection.java:472)
at com.cloudbees.jenkins.plugins.sshcredentials.impl.TrileadSSHPublicKeyAuthenticator.doAuthenticate(TrileadSSHPublicKeyAuthenticator.java:110)
at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.authenticate(SSHAuthenticator.java:431)
at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.authenticate(SSHAuthenticator.java:468)
at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:881)
at hudson.plugins.sshslaves.SSHLauncher.lambda$launch$0(SSHLauncher.java:434)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.io.IOException: Could not generate signature
at com.trilead.ssh2.signature.KeyAlgorithm.generateSignature(KeyAlgorithm.java:43)
at com.trilead.ssh2.auth.AuthenticationManager.authenticatePublicKey(AuthenticationManager.java:316)
... 10 more
Caused by: java.security.SignatureException: Could not sign data
at java.base/sun.security.rsa.RSASignature.engineSign(RSASignature.java:196)
at java.base/java.security.Signature$Delegate.engineSign(Signature.java:1423)
at java.base/java.security.Signature.sign(Signature.java:712)
at com.trilead.ssh2.signature.KeyAlgorithm.generateSignature(KeyAlgorithm.java:41)
... 11 more
Caused by: javax.crypto.BadPaddingException: RSA private key operation failed
at java.base/sun.security.rsa.RSACore.crtCrypt(RSACore.java:209)
at java.base/sun.security.rsa.RSACore.rsa(RSACore.java:130)
at java.base/sun.security.rsa.RSASignature.engineSign(RSASignature.java:193)
... 14 more
[08/24/22 14:39:14] [SSH] Authentication failed.
From the machine on which Jenkins is installed, I can connect to a remote one using:
ssh name@host -p 22
All the solutions I found to this issue were solved through the console under the user Jenkins But how to solve this issue using the jenkins UI, because the connection to the previously created Node is active, the problems are only with this. Maybe he indicated something wrong
The private key was created using:
ssh-keygen -t rsa
I took the key from rsa_id
Solution
I had the same issue. I think it's a bug.
I changed the type of ssh-key to ed25519 and it worked.
ssh-keygen -t ed25519
Answered By - Eduardo
Answer Checked By - Pedro (JavaFixing Volunteer)