![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) SSH Authentication using an SSH CertificateSee more SSH ExamplesDemonstrates how to authenticate using an SSH certificate.Note: This example requires Chilkat v11.0.0 or greater. For more information, see https://www.chilkatsoft.com/understanding_ssh_certificates.asp
Use ChilkatAx-win32.pkg Procedure Test Handle hoSbSshCert Boolean iSuccess Handle hoSbPrivKey Variant vKey Handle hoKey Handle hoSsh String sHostname Integer iPort String sTemp1 // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatStringBuilder)) To hoSbSshCert If (Not(IsComObjectCreated(hoSbSshCert))) Begin Send CreateComObject of hoSbSshCert End Get ComLoadFile Of hoSbSshCert "qa_data/sshCert/user_ecdsa_key-cert.pub" "utf-8" To iSuccess If (iSuccess = False) Begin Showln "Failed to load user_ecdsa_key-cert.pub" Procedure_Return End Get Create (RefClass(cComChilkatStringBuilder)) To hoSbPrivKey If (Not(IsComObjectCreated(hoSbPrivKey))) Begin Send CreateComObject of hoSbPrivKey End Get ComLoadFile Of hoSbPrivKey "qa_data/sshKeys/user_ecdsa_key" "utf-8" To iSuccess If (iSuccess = False) Begin Showln "Failed to load user_ecdsa_key" Procedure_Return End Get Create (RefClass(cComChilkatSshKey)) To hoKey If (Not(IsComObjectCreated(hoKey))) Begin Send CreateComObject of hoKey End // Provide the password if the user_ecdsa_key is stored in an encrypted format. Set ComPassword Of hoKey To "secret" Get ComGetAsString Of hoSbPrivKey To sTemp1 Get ComFromOpenSshPrivateKey Of hoKey sTemp1 To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoKey To sTemp1 Showln sTemp1 Procedure_Return End // Indicate that the SSH certificate is to be used for authentication. // The UseSshCertificate method was added in Chilkat v11.0.0 Get ComGetAsString Of hoSbSshCert To sTemp1 Get ComUseSshCertificate Of hoKey sTemp1 To iSuccess Get Create (RefClass(cComChilkatSsh)) To hoSsh If (Not(IsComObjectCreated(hoSsh))) Begin Send CreateComObject of hoSsh End Move "ssh.example.com" To sHostname Move 22 To iPort Get ComConnect Of hoSsh sHostname iPort To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoSsh To sTemp1 Showln sTemp1 Procedure_Return End Get pvComObject of hoKey to vKey Get ComAuthenticatePk Of hoSsh "myLogin" vKey To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoSsh To sTemp1 Showln sTemp1 Procedure_Return End Showln "Public-Key Authentication using an SSH Certificate was Successful!" End_Procedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.