SwiftSH icon indicating copy to clipboard operation
SwiftSH copied to clipboard

Authenticating with Public/Private key

Open jesper-bylund opened this issue 6 years ago • 3 comments

Not really an issue I guess, more an open question:

I'm trying to open a shell with an RSA key, but I can't quite follow the code to see how that's done. Am I right in believing I should be using the authorise() method? The challenge seems to accept public/private keys, but I can't figure out how.

jesper-bylund avatar Jun 30 '19 08:06 jesper-bylund

I'm trying the following:

self.authenticationChallenge = .byPublicKey(username: self.username, password: self.password, publicKey: self.publicKey, privateKey: self.privateKey)

But I get this response:

DEBUG: Timeout set to 10.0 seconds
INFO: Libssh2 v1.8.0
DEBUG: ec2-54-77-251-54.eu-west-1.compute.amazonaws.com resolved. 1 addresses
WARN: Connection to 54.77.251.54 on port 22 failed
INFO: Bye bye
DEBUG: Disconnected

The username and keys are hardcoded and work fine using vanilla NSSH (but I can't get that shell to work). There is however no password, just an empty string. Could that create this issue? How can I debug the challenge?

jesper-bylund avatar Jun 30 '19 10:06 jesper-bylund

Strangely, this code actually does work. But only 1 out of 3 times. No idea why as I'm unsure how to debug.

jesper-bylund avatar Jun 30 '19 11:06 jesper-bylund

I had a similar issue which was caused by a very short timeout creating the connection. See PR https://github.com/Frugghi/SwiftSH/pull/28.

bakertim avatar Sep 18 '19 18:09 bakertim