Can someone give me an example of private / public key authentication in sshj ?
In sshj, which is equivalent to the command line,
ssh -i /path/to/mykey.private username@host
I tried (processing error omitted)
final SSHClient ssh = new SSHClient(); ssh.loadKnownHosts(); ssh.connect("host"); ssh.authPublickey("username", "/path/to/mykey.private"); final Session session = ssh.startSession(); ...
but in the log statements that I see
DEBUG net.schmizz.sshj.SSHClient - Attempting to load key from: /path/to/mykey.private WARN net.schmizz.sshj.SSHClient - Could not load keys due to: {} net.schmizz.sshj.common.SSHException: No provider available forUnknown key file at net.schmizz.sshj.SSHClient.loadKeys(SSHClient.java:482) ~[sshj-0.3.0.jar:na] ... Exception in thread "main" 10:49:55.943 [reader] DEBUG net.schmizz.sshj.transport.Reader - Stopping net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods
Thanks Everett
java ssh sshj
Everett toews
source share