Archived Forum Post

Index of archived forum posts

Question:

FTP using a private key file

Apr 18 '14 at 11:51

I need to use ftp2 in classic asp to connect to an ftp site that requires the use of a private key file (xxx.ppx). Has anyone done this?

Thanks.


Answer

This is Perl but same concept.

Load up the key into CkSshKey, openSshPrivateKey, and AuthenticatePK. There is another method if both the key and password is required.

if (length($f->privatekey) && $f->privatekey ne "NULL")

{
   $key = new chilkat::CkSshKey();
   $privKey = $key->loadText($pkey);
   if ($privKey eq "" ) {
              $message="Load Private Key Error \n" . $ftp->lastErrorText();
              $cm->Comment($message,1);
      return $message;
}
    $success = $key->FromOpenSshPrivateKey($privKey);
    if ($success != 1) {
              $message="Private Key Error \n" . $ftp->lastErrorText();
              $cm->Comment($message,1);
      return $message;
    }
    $success = $ftp->AuthenticatePk($f->myftpuser,$key);
    if ($success != 1) {
              $message="Key authenticate Error \n" . $ftp->lastErrorText();
              $cm->Comment($message,1);
      return $message;
    }

Answer

also ftp does not have public and private keys, only sftp.