Subject: Re: Authentication using public/private key

Re: Authentication using public/private key

From: Ted Lemon <mellon_at_fugue.com>
Date: Tue, 10 Aug 2010 12:00:54 -0400

On Aug 10, 2010, at 6:36 AM, Paresh Thakor wrote:
> I'm implementing libssh2 for ssh implementation for my iPhone application. If anyone good to this, please let me know how can i put these files and where to put them? In documents directory for iPhone application? Or how can we access these files globally? I've tried few tricks but each of them failed. Please let me know how can i implement public/private key authorization.

The easiest way to do this, just to try it out, is to put the files in the Resources folder in your xcode project. This will result in them being copied into the application bundle. You can then open them with this example code:

      privkey = [[NSBundle mainBundle] pathForResource: @"ipad" ofType: @"key"
                                       inDirectory: @""];
      pubkey = [[NSBundle mainBundle] pathForResource: @"ipad" ofType: @"pub"
                                      inDirectory: @""];
      rc = libssh2_userauth_publickey_fromfile(session,
                                               "mellon", [pubkey UTF8String],
                                               [privkey UTF8String], "");

However, obviously this won't work for production use, since the user needs to set up their own key. For that, I think the right solution is to port the ssh-keygen functionality and generate the key on the iPad; any other solution is going to be impractical, because it will rely on some resource the user may or may not have (a machine that can run ssh-keygen), and on a secure path between the user's machine and the machine that generated the key, which is a bit of a chicken-and-egg problem. You could use iTunes file transfer for this, but I don't think it's at all secure.

I'm working on an app for iPad that uses libssh2 as well, and so I'm running into similar problems--if I come up with a solution I'll let you know.

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-08-10