Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PHP Extension) Load SSH Keys Produced by ssh-keygenDemonstrates how to load the public and private keys produced by ssh-keygen.
<?php // The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number. // For example, if using Chilkat v9.5.0.48, then include as shown here: include("chilkat_9_5_0.php"); // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // We first generate a key like this: // ssh-keygen -f stg.chilkat.id // Generating public/private rsa key pair. // Enter passphrase (empty for no passphrase): // Enter same passphrase again: // Your identification has been saved in stg.chilkat.id. // Your public key has been saved in stg.chilkat.id.pub. // The key fingerprint is: // SHA256:hkbgexkspxYTa8rYUxouRU8Gi7lbbsT6dSLX+JlStKk me@example02240 // The key's randomart image is: // +---[RSA 2048]----+ // | o.= | // | + * = | // |o + X = | // | O * O.+ | // |+ @ +.=oS | // | A o =+. | // |o + =oo | // | o +E+ o | // | . .+ | // +----[SHA256]-----+ // // The public key (generated to the file stg.chilkat.id.pub) contains this: // ssh-rsa AAAAB3NzaC1yc2EAAAADAQABA.. FDt+dKJEkhw8I7LpEi17diB9 me@example02240 // First let's load the public key: $pubkey = new CkSshKey(); $success = $pubkey->FromOpenSshPublicKey($pubkey->loadText('qa_data/sshKeys/ssh-keygen/stg.chilkat.id.pub')); if ($success == false) { print $pubkey->lastErrorText() . "\n"; exit; } print $pubkey->lastErrorText() . "\n"; print 'Successfully loaded the public key.' . "\n"; // Now try the private key, which contains this: // -----BEGIN OPENSSH PRIVATE KEY----- // b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn // NhA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nefX4AgKA7nplCRUANLbvTACTazHtcBAAAAgQCihdCPzywEkrn0VhYIOV // sK7oIUD/EBEzb7yL+7naZqACStbhKiLKGgSJj2+3hgmQk2tZ94zN5lkCcLLFy9Ai47HkN+ // dSmZqac5pQeVyWrJ/67OSqWxMFfjkbF/0IxXJM2y+i//vGWBDo3NJmkYGwY+XnFP81qqh9 // boeQA0K6wn0wAAAIEA2tX2lZrwAyhl/L5XY1xsQ3uuoaIUeZD0vUs+mAv1pz8fbTAD2n37 // Rh57mxDNQIwiD8lV5wZ20NP03nAr8gUQaijsBRy3gDXHX7Qa/BaJ2bY0492HXwVYi9bsng // GJQinYjmJQQeR/w4u5rNzuD8y1ysMwh/sE8IGu6LLG1IBDYr0AAACBAMord/G9vderFO+1 // tNZHl09m9mFLJTHRVH41Da2uCl2KJnYir511M9GSG9Un6L+UGu4F9CrypehgJHZ6QbwpgS // JrwlCfE09jPkuH0aktg9fnrrEJYS30wWNNSj1v/91v1F3fdrZePd+UnKcP6zZB3jICzPhW // elU1OYdWf+qFrnDBAAAAGWRqYWNrc29uMDIyQGRqYWNrc29uMDIyNDAB // -----END OPENSSH PRIVATE KEY----- $privkey = new CkSshKey(); $success = $privkey->FromOpenSshPrivateKey($pubkey->loadText('qa_data/sshKeys/ssh-keygen/stg.chilkat.id')); if ($success == false) { print $privkey->lastErrorText() . "\n"; exit; } print $privkey->lastErrorText() . "\n"; print 'Successfully loaded the private key.' . "\n"; ?> |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.