[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question on ssh_auth_pubkey (was: privatekey_from_file)


On Tue, 2009-12-22 at 11:54 +0100, Andreas Schneider wrote:
> The pubkey and autopubkey auth function should be reworked to get the key from 
> the private key if we can't find a public key.

Hmm... after some checking in auth.c, it seems there's no way to change
ssh_auth_pubkey() function to check the existence of a .pub file, since
it does not have a file name parameter. So how about this:

1. In ssh_auth_pubkey(), if publickey is NULL, call
publickey_from_privatekey() to generate it.

2. Add a new function ssh_auth_privatekey_file(), which takes the file
name and passphrase of the private key as parameter. The logic looks
like:
ssh_auth_privatekey_file(keyfile, passphrase) {
  if (exists <keyfile>.pub) {
    pubkey = publickey_from_file(<keyfile>.pub, &keytype);
    privkey = privatekey_from_file(<keyfile>, keytype, passphrase);
    ssh_auth_pubkey(pubkey, privkey);
  }
  else {
    /* auto-detect private key type */
    privkey = privatekey_from_file(<keyfile>, 0, passphrase);
    /* auto-generate pubkey implemented in 1. above */
    ssh_auth_pubkey(NULL, privkey);
  }
}

How do you think?

Vic



Follow-Ups:
Re: Question on ssh_auth_pubkey (was: privatekey_from_file)Andreas Schneider <mail@xxxxxxxxxxxx>
References:
Question on privatekey_from_fileVic Lee <llyzs@xxxxxxx>
Re: Question on privatekey_from_fileVic Lee <llyzs@xxxxxxx>
Re: Question on privatekey_from_fileVic Lee <llyzs@xxxxxxx>
Re: Question on privatekey_from_fileAndreas Schneider <mail@xxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org