et.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods
- Dominant language
- Java
- Stars
- 2.7k
- Forks
- 620
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 11
Description
Hi,
Let me explain my problem !
I am trying to authenticate using rsa keys & passphrase
I'm using sshj 0.23.0 & bc 1.59
Let me know if I do something wrong !!
Thanks !
**Code used:**
`privateKey = readFile("../clef/id_rsa");`
`publicKey = readFile("../clef/id_rsa.pub");`
`passphrase = readFile("../clef/passphrase");`
`System.out.println("privateKey = " + privateKey);`
`System.out.println("publicKey = " + publicKey);`
`System.out.println("passphrase = " + passphrase);`
`OpenSSHKeyFile key; `
`key = new OpenSSHKeyFile();`
`key.init(new File("../clef/id_rsa"),new StaticPasswordFinder(passphrase)); `
`try`
`{`
` System.out.println("Authentificate with user & passphrase" + user + " (key)");`
` ssh.authPublickey(user, key);`
` System.out.println("Authentificate with user & passphrase" + user + " (key) DONE ");`
`}`
` catch (UserAuthException e)`
`{`
` System.out.println(e.getMessage());`
` e.printStackTrace();`
`}`
**And the output log**
> **************************************************************************
**************************************************************************
privateKey = -----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,734464E5476E57E6
J4dcVV3tp56KM/4zDc2ypNhewRKGEo9KPV1Qhm+5fpFehBGDIitlZQHtOnr6QipC
creSKmXvreEFVxg1E1BccoyCqZiU+atd9vHUj0DTYZ5zqsrg4cf66RJ9lwz60tWE
RLlbrkzXQCOJaPb2K9qr/m+222eVxulUijL+DjqV4eE32Se+43fRnTumBnnKoog1
YyeqaGWw3IvTfFUu729tqzqKNBgQrmRo057qqj2EJO6c5k9wEhlzE5Cl9JL+VLdM
mx6S5yr02UDqycbhhUKviRETHbUcf7IZeLzUmSOmoWYqj7klf3oWk+sQ6sNCTtaZ
dvQWnCOrwbCDR8YaMOimdFgWPelrfWOQJR2xJ9xaHxCa5O6MgPDgWXz/3WUbFpau
PMUChuFwueTLXbg1bD6eiQdOGAzw9c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JxKnfnt9LSqYSHuGuYvkMKd7AekbSvIVOO+7bSyDg4KYXOQlm1jc8aXJwPUtIWKW
jHURWXp55ABZY7yEv4N5rBwvYUMbdsd6K34RzIqIzeLP5s5+khzhqw==
-----END RSA PRIVATE KEY-----
publicKey = ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEA4qA6GqQmf4Xoq5Mm/3UBhQ8RARxB0w7eitivaqvPJHqQknHHEaz/7bEgFjKfNTmTy08aRGmoIe5Wlp/meoBzSM+JodtEbYQSjWhfWtuvU6sXw+TlK2kv8Exdh8DSbRfH6tPg+vFvkTFF2pC+pXY8FCcmPcPOHs4Pjm0kkJ5bSZTkJInlTXHJlQWJQl85N5Ka7OVJaCAnQnyO7ogyVl/C/JOmlBDsST1cf2iMYlVrvH1CVyLEasEYdCmfRQlUvp8aIGa2+0R2jUcDmvME1MG03S8eaxJeb8demHmPD0f0cIPhMLLixvabAPyEpWM6ZRECVd2pR0jPO+LNanlWtp5Tow==
passphrase = 1p@ssw0rd
Authentificate with user & passphrasedune (key)
[main] DEBUG net.schmizz.concurrent.Promise - Setting <> to `null`
[main] DEBUG net.schmizz.sshj.transport.TransportImpl - Sending SSH_MSG_SERVICE_REQUEST for ssh-userauth
[main] DEBUG net.schmizz.concurrent.Promise - Awaiting <>
[reader] DEBUG net.schmizz.concurrent.Promise - Setting <> to `SOME`
[main] DEBUG net.schmizz.sshj.transport.TransportImpl - Setting active service to ssh-userauth
[main] DEBUG net.schmizz.concurrent.Promise - Setting <> to `null`
[main] DEBUG net.schmizz.sshj.userauth.UserAuthImpl - Trying `publickey` auth...
[main] DEBUG net.schmizz.sshj.userauth.method.AuthPublickey - Attempting authentication using PKCS8KeyFile{resource=[PrivateKeyFileResource] D:\PLATFORM_INSTALLER\test_sshj\..\clef\id_rsa}
[main] DEBUG net.schmizz.concurrent.Promise - Awaiting <>
[reader] DEBUG net.schmizz.sshj.userauth.UserAuthImpl - Asking `publickey` method to handle USERAUTH_60 packet
[reader] DEBUG net.schmizz.sshj.userauth.method.AuthPublickey - Key acceptable, sending signed request
[reader] DEBUG net.schmizz.sshj.userauth.method.AuthPublickey - Attempting authentication using PKCS8KeyFile{resource=[PrivateKeyFileResource] D:\PLATFORM_INSTALLER\test_sshj\..\clef\id_rsa}
[main] ERROR net.schmizz.concurrent.Promise - <> woke to: **net.schmizz.sshj.userauth.UserAuthException: Problem getting private key from PKCS8KeyFile**{resource=[PrivateKeyFileResource] D:\PLATFORM_INSTALLER\test_sshj\..\clef\id_rsa}
Exhausted available authentication methods
**net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods**
at net.schmizz.sshj.SSHClient.auth(SSHClient.java:231)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:346)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:365)
at jobExecution.main(jobExecution.java:156)
**Caused by: net.schmizz.sshj.userauth.UserAuthException: Problem getting private key from PKCS8KeyFile**{resource=[PrivateKeyFileResource] D:\PLATFORM_INSTALLER\test_sshj\..\clef\id_rsa}
at net.schmizz.sshj.userauth.method.KeyedAuthMethod.putSig(KeyedAuthMethod.java:61)
at net.schmizz.sshj.userauth.method.AuthPublickey.sendSignedReq(AuthPublickey.java:74)
at net.schmizz.sshj.userauth.method.AuthPublickey.handle(AuthPublickey.java:45)
at net.schmizz.sshj.userauth.UserAuthImpl.handle(UserAuthImpl.java:142)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:500)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:102)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:170)
at net.schmizz.sshj.transport.Reader.run(Reader.java:59)
**Caused by: org.bouncycastle.openssl.EncryptionException: exception using cipher - please check password and data**.
at org.bouncycastle.openssl.jcajce.PEMUtilities.crypt(Unknown Source)
at org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder$1$1.decrypt(Unknown Source)
at org.bouncycastle.openssl.PEMEncryptedKeyPair.decryptKeyPair(Unknown Source)
at net.schmizz.sshj.userauth.keyprovider.PKCS8KeyFile.readKeyPair(PKCS8KeyFile.java:73)
at net.schmizz.sshj.userauth.keyprovider.BaseFileKeyProvider.getPrivate(BaseFileKeyProvider.java:75)
at net.schmizz.sshj.userauth.method.KeyedAuthMethod.putSig(KeyedAuthMethod.java:59)
... 7 more
**Caused by: javax.crypto.BadPaddingException: pad block corrupted**
at org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher$BufferedGenericBlockCipher.doFinal(Unknown Source)
at org.bouncycastle.jcajce.provider.symmetric.util.BaseBlockCipher.engineDoFinal(Unknown Source)
at javax.crypto.Cipher.doFinal(Cipher.java:2164)
... 13 more
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.