![]() |
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
(PowerBuilder) 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
integer li_rc oleobject loo_SbSshCert integer li_Success oleobject loo_SbPrivKey oleobject loo_Key oleobject loo_Ssh string ls_Hostname integer li_Port // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_SbSshCert = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbSshCert.ConnectToNewObject("Chilkat.StringBuilder") if li_rc < 0 then destroy loo_SbSshCert MessageBox("Error","Connecting to COM object failed") return end if li_Success = loo_SbSshCert.LoadFile("qa_data/sshCert/user_ecdsa_key-cert.pub","utf-8") if li_Success = 0 then Write-Debug "Failed to load user_ecdsa_key-cert.pub" destroy loo_SbSshCert return end if loo_SbPrivKey = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbPrivKey.ConnectToNewObject("Chilkat.StringBuilder") li_Success = loo_SbPrivKey.LoadFile("qa_data/sshKeys/user_ecdsa_key","utf-8") if li_Success = 0 then Write-Debug "Failed to load user_ecdsa_key" destroy loo_SbSshCert destroy loo_SbPrivKey return end if loo_Key = create oleobject // Use "Chilkat_9_5_0.SshKey" for versions of Chilkat < 10.0.0 li_rc = loo_Key.ConnectToNewObject("Chilkat.SshKey") // Provide the password if the user_ecdsa_key is stored in an encrypted format. loo_Key.Password = "secret" li_Success = loo_Key.FromOpenSshPrivateKey(loo_SbPrivKey.GetAsString()) if li_Success = 0 then Write-Debug loo_Key.LastErrorText destroy loo_SbSshCert destroy loo_SbPrivKey destroy loo_Key return end if // Indicate that the SSH certificate is to be used for authentication. // The UseSshCertificate method was added in Chilkat v11.0.0 loo_Key.UseSshCertificate(loo_SbSshCert.GetAsString()) loo_Ssh = create oleobject // Use "Chilkat_9_5_0.Ssh" for versions of Chilkat < 10.0.0 li_rc = loo_Ssh.ConnectToNewObject("Chilkat.Ssh") ls_Hostname = "ssh.example.com" li_Port = 22 li_Success = loo_Ssh.Connect(ls_Hostname,li_Port) if li_Success <> 1 then Write-Debug loo_Ssh.LastErrorText destroy loo_SbSshCert destroy loo_SbPrivKey destroy loo_Key destroy loo_Ssh return end if li_Success = loo_Ssh.AuthenticatePk("myLogin",loo_Key) if li_Success <> 1 then Write-Debug loo_Ssh.LastErrorText destroy loo_SbSshCert destroy loo_SbPrivKey destroy loo_Key destroy loo_Ssh return end if Write-Debug "Public-Key Authentication using an SSH Certificate was Successful!" destroy loo_SbSshCert destroy loo_SbPrivKey destroy loo_Key destroy loo_Ssh |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.