NMSSH / NMSSH

NMSSH is an Objective-C wrapper for libssh2, with a sweet API.
http://cocoadocs.org/docsets/NMSSH/
MIT License
749 stars 236 forks source link

authenticate with default user config/environment ? #116

Open nicolaslauquin opened 9 years ago

nicolaslauquin commented 9 years ago

I used with success the authenticateByPrivateKey:privateKey:andPassword but is there a way to load the default user configuration without providing privateKey and password, like when a user open its terminal and you enter ssh user@host ?

My goal would be to test the connection first with the default user ssh key and if not available prompt the user for password. Maybe I missed something in the api ? If it is not the scope of NMSSH, do you have an idea how to address that point ?

Thank you

bhr commented 9 years ago

AFAIK there is no general default user and password. Depending on the host, there may be a default configuration you can try out first by calling authenticateByPrivateKey:privateKey:andPassword and look if authentication succeeds. If not, you can ask for username and password.

nicolaslauquin commented 9 years ago

@bhr the problem is that I don't know the user's password for the private certificate so calling authentificateByPrivateKey is useless whiteout that information.

I looked in the Keychain Access app and there is an entry for the default user id_rsa called SSH: /Users/XXX/.ssh/id_rsa. It gives access for free to ssh-agent, ssh-add and ssh, this is why we don't have to enter password in terminal.

I'm gonna dig that track to get access to that password and provide easy connectivity for that main scenario (but won't cover all of them I'm aware of that).

bhr commented 9 years ago

I see. Thanks for providing more information what you want to achieve.

I think the easiest way is to ask the user at first launch for this password and then store it yourself in keychain. I doubt you have access to the default SSH entries.

Another idea is to look how similar apps are behaving. I'm thinking of 3rd-party git apps like Tower, SourceTree or GitX. They use SSH keys, but I think they ask users upfront for passwords as well (actually I can't remember for sure).