![]() |
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
(Visual FoxPro) 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
LOCAL loSbSshCert LOCAL lnSuccess LOCAL loSbPrivKey LOCAL loKey LOCAL loSsh LOCAL lcHostname LOCAL lnPort * This example assumes the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbSshCert = CreateObject('Chilkat.StringBuilder') lnSuccess = loSbSshCert.LoadFile("qa_data/sshCert/user_ecdsa_key-cert.pub","utf-8") IF (lnSuccess = 0) THEN ? "Failed to load user_ecdsa_key-cert.pub" RELEASE loSbSshCert CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbPrivKey = CreateObject('Chilkat.StringBuilder') lnSuccess = loSbPrivKey.LoadFile("qa_data/sshKeys/user_ecdsa_key","utf-8") IF (lnSuccess = 0) THEN ? "Failed to load user_ecdsa_key" RELEASE loSbSshCert RELEASE loSbPrivKey CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.SshKey') loKey = CreateObject('Chilkat.SshKey') * Provide the password if the user_ecdsa_key is stored in an encrypted format. loKey.Password = "secret" lnSuccess = loKey.FromOpenSshPrivateKey(loSbPrivKey.GetAsString()) IF (lnSuccess = 0) THEN ? loKey.LastErrorText RELEASE loSbSshCert RELEASE loSbPrivKey RELEASE loKey CANCEL ENDIF * Indicate that the SSH certificate is to be used for authentication. * The UseSshCertificate method was added in Chilkat v11.0.0 loKey.UseSshCertificate(loSbSshCert.GetAsString()) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Ssh') loSsh = CreateObject('Chilkat.Ssh') lcHostname = "ssh.example.com" lnPort = 22 lnSuccess = loSsh.Connect(lcHostname,lnPort) IF (lnSuccess <> 1) THEN ? loSsh.LastErrorText RELEASE loSbSshCert RELEASE loSbPrivKey RELEASE loKey RELEASE loSsh CANCEL ENDIF lnSuccess = loSsh.AuthenticatePk("myLogin",loKey) IF (lnSuccess <> 1) THEN ? loSsh.LastErrorText RELEASE loSbSshCert RELEASE loSbPrivKey RELEASE loKey RELEASE loSsh CANCEL ENDIF ? "Public-Key Authentication using an SSH Certificate was Successful!" RELEASE loSbSshCert RELEASE loSbPrivKey RELEASE loKey RELEASE loSsh |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.