Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(MFC) Get SSH Server Authentication MethodsDemonstrates how to get the authentication methods of an SSH server. This example requires Chilkat v9.5.0.78 or greater.
#include <CkSsh.h> void ChilkatSample(void) { CkString strOut; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkSsh ssh; // To get the authentication methods offered by an SSH server, we first connect. bool success = ssh.Connect("example.com",22); if (success != true) { strOut.append(ssh.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } // Next, we call GetAuthMethods to receive a comma separated list of authentication methods const char *authMethods = ssh.getAuthMethods(); if (ssh.get_LastMethodSuccess() != true) { strOut.append(ssh.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } // For example: publickey,password,keyboard-interactive strOut.append("Authentication methods suported by this serve: "); strOut.append(authMethods); strOut.append("\r\n"); // IMPORTANT: // Getting the authentication methods will intentionally disconnect from the server. // We'll need to re-connect, etc. to continue.. // For example.. bool success = ssh.Connect("example.com",22); if (success != true) { strOut.append(ssh.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } success = ssh.AuthenticatePw("myLogin","myPassword"); if (success != true) { strOut.append(ssh.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } strOut.append("SSH Authentication successful."); strOut.append("\r\n"); // ... ssh.Disconnect(); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.