Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication Failed using Private Key,Public Key #145

Closed
ios-52 opened this issue Apr 21, 2023 · 15 comments
Closed

Authentication Failed using Private Key,Public Key #145

ios-52 opened this issue Apr 21, 2023 · 15 comments

Comments

@ios-52
Copy link

ios-52 commented Apr 21, 2023

Hello
We are trying to connect our Mac and aws servers using the private key. but every time we got authentication failed.
Also, we have checked both keys on another application and it's working fine.so I think the problem is in the library. can you please help?

using this method

.byPublicKeyFromFile(username: self.username, password: "", publicKey: "", privateKey: pvtfilePath?.relativePath ?? "")

but not working can you please help us

@Lukasa
Copy link
Collaborator

Lukasa commented Apr 21, 2023

Can you show me the complete code for how you configure your client?

@ios-52
Copy link
Author

ios-52 commented Apr 21, 2023

Here is my code.
Please help us

var session: NMSSHSession?
session = NMSSHSession(host: "192.168.0.228", port: Int(connection.port), andUsername: "Jigar D")
var pubfilePath = Bundle.main.url(forResource:"Jigarid_rsa", withExtension: "pub")
            var pvtfilePath = Bundle.main.url(forResource:"Jigarid_rsa", withExtension: "")
            session?.authenticate(byPublicKey: pubfilePath?.relativePath ?? "", privateKey: pvtfilePath?.relativePath ?? "", andPassword: "")

@Lukasa
Copy link
Collaborator

Lukasa commented Apr 21, 2023

Without knowing the NMSSHSession code it's very hard to be more helpful. Is that code available anywhere?

@ios-52
Copy link
Author

ios-52 commented Apr 21, 2023

We are using this file please check
Archive 3.zip

@Lukasa
Copy link
Collaborator

Lukasa commented Apr 24, 2023

Your code appears to be using libssh2. Unfortunately, I can't provide support for libssh2 here, as this repository is unrelated. libssh2 has its own issue tracker, so you'll need to ask for support over there.

@Lukasa Lukasa closed this as completed Apr 24, 2023
@ios-52
Copy link
Author

ios-52 commented Apr 24, 2023

@Lukasa We already generate issue but not provide any solution.I think this library also used LibSSH2 because without that how can we connect server.

@Lukasa
Copy link
Collaborator

Lukasa commented Apr 24, 2023

swift-nio-ssh does not use libssh2, it is a ground-up reimplementation of the SSH wire protocol.

@ios-52
Copy link
Author

ios-52 commented Apr 24, 2023

NMSSHSession in this file its already used libssh2_userauth_publickey_fromfile.we are also used this method
Screenshot 2023-04-24 at 5 55 12 PM

@Lukasa
Copy link
Collaborator

Lukasa commented Apr 24, 2023

NMSSHSession and swift-nio-ssh are entirely unrelated. swift-nio-ssh and libssh2 are entirely unrelated. I cannot support you with issues with libssh2.

@ios-52
Copy link
Author

ios-52 commented Apr 24, 2023

@Lukasa So if we are use this library than it will support ssh authenticate using private key?

@Lukasa
Copy link
Collaborator

Lukasa commented Apr 24, 2023

Yes, swift-nio-ssh supports SSH private key authentication.

@ios-52
Copy link
Author

ios-52 commented Apr 24, 2023

For SSH private key authentication. need to use this method?
Screenshot 2023-04-24 at 6 00 06 PM

@Lukasa
Copy link
Collaborator

Lukasa commented Apr 24, 2023

No, NMSSHSession and swift-nio-ssh are unrelated. You would use entirely different API calls.

@ios-52
Copy link
Author

ios-52 commented Apr 24, 2023

@Lukasa if possible can you please provide link or demo ?

@Lukasa
Copy link
Collaborator

Lukasa commented Apr 24, 2023

There is an example in this repository. Alternatively, you could investigate Citadel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants