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
(Unicode C) Load PuTTY Private KeyLoads a PuTTY private key into an SSH key object.
#include <C_CkStringBuilderW.h> #include <C_CkSshKeyW.h> void ChilkatSample(void) { HCkStringBuilderW sb; BOOL bCrlf; HCkSshKeyW sshKey; BOOL success; sb = CkStringBuilderW_Create(); bCrlf = TRUE; CkStringBuilderW_AppendLine(sb,L"PuTTY-User-Key-File-2: ssh-rsa",bCrlf); CkStringBuilderW_AppendLine(sb,L"Encryption: aes256-cbc",bCrlf); CkStringBuilderW_AppendLine(sb,L"Comment: rsa-key-20161121",bCrlf); CkStringBuilderW_AppendLine(sb,L"Public-Lines: 6",bCrlf); CkStringBuilderW_AppendLine(sb,L"AAAAB3NzaC1yc2EAAAABJQAAAQEArIVxZTGYjqqNegJeMqgZzXKuX3YtxmD4DPnQ",bCrlf); CkStringBuilderW_AppendLine(sb,L"K01SXoR9UA4wl6RJK5FGonI5spVnddr6HJny0eY5/RmV1dyL0fNdH2pfnHHoTd9B",bCrlf); CkStringBuilderW_AppendLine(sb,L"uXG0PcTn4BqJFlybC6NNaGaByqpNPaOgjJIMHXTaeCuDuzwP02f3UKSfLAFdvUNP",bCrlf); CkStringBuilderW_AppendLine(sb,L"fX3yrMRabjVcHJpgUn535Y9Y3ZphSFssiElLpp1vo6QLsdiAl0wgU4HLw9Dfg8sh",bCrlf); CkStringBuilderW_AppendLine(sb,L"p3zgAufYUUIx2HChITJ7OO/PH5GEbPvJFbYH4Wx33GEe56JCF9QxxDCqNxsPMrvu",bCrlf); CkStringBuilderW_AppendLine(sb,L"mqkSIPIELFl5zVYSFD9PiL8RZQcPJGq5zbF9+szsS/6DSH8biw==",bCrlf); CkStringBuilderW_AppendLine(sb,L"Private-Lines: 14",bCrlf); CkStringBuilderW_AppendLine(sb,L"SVqUm9zBUN6zaAaUY6TLnIXAhxqv4s1UhzukcN7Ns0Fs1EqdDP4nVMKgmiDxHaAj",bCrlf); CkStringBuilderW_AppendLine(sb,L"ucb1PLv7uj2eGt69E+HKH4AC2LtJZNH4qLw+p8QKqdN79oRAMHwtS4cU88eeQ91t",bCrlf); CkStringBuilderW_AppendLine(sb,L"2W3wzmTzvYFlE6VbUr3bNl3f68OCQHz+7YJuL8g0eclNuveHB/VmBqnek1LL/cRY",bCrlf); CkStringBuilderW_AppendLine(sb,L"wmk8wyzHRl7X8fyjGX0PiOPyVwXBDJFNjjKAdrRCRS0Cc4PWAb/18qrA9ApArQVk",bCrlf); CkStringBuilderW_AppendLine(sb,L"a5miOMfrXFF2Vg3JyNgfdDilNKkry9x5oTtfueZkFgu/6pofP5qrTstr+BmB16mu",bCrlf); CkStringBuilderW_AppendLine(sb,L"MxcDRF+jOm9XvU1OnrzQ9rBzuaHEfhSHqlKyMGTDuzRtNyxlDBgK4DaZ2z1FJQGF",bCrlf); CkStringBuilderW_AppendLine(sb,L"63p36KgVqx571PUJ8P/28VUb6s/OtXcjhxxvhC8Eo0wrTdjzDiX+IovdjOhWgn4v",bCrlf); CkStringBuilderW_AppendLine(sb,L"xugaYocotTbhqq+O1w9xYtmG8fP921+TIpHzCkE8QTJzLJ40pemKZ+TAOmhb0OUQ",bCrlf); CkStringBuilderW_AppendLine(sb,L"jemqmRohcxx7NEoZ0TsoAe6i+GQJ2cEE7LcNcSX3V66AkyTsTieqk1nSxyHyoF+l",bCrlf); CkStringBuilderW_AppendLine(sb,L"rTaVOhFM5H8Etzv94SP3c1if3Qa9cmZaEmfaqrS94bzX+OY/zRIFweT0BeMo3Uac",bCrlf); CkStringBuilderW_AppendLine(sb,L"fP6gBDBiLYZeRURcx0mYRdNYlssaKoYLA6c7F3ggo34VfgD6LP+ZYnG8yAXGXSPr",bCrlf); CkStringBuilderW_AppendLine(sb,L"lgrfdg/szqSsOKVdkoGTkVy+BgrhITnFIs8TLZsrtSEPmXjEa+QvdP6FPsyN5u6P",bCrlf); CkStringBuilderW_AppendLine(sb,L"8s0i8EC0KT0YA77Ps29DEU3fxsXVSc9Xd9qdiWfJ0ce2hOsTwxL1gxtXUKP4xCzm",bCrlf); CkStringBuilderW_AppendLine(sb,L"oXaWLFajiws2EjgBbwREj12v0I2N4xrpf/PeJq22EvWLYm9H94DdFrkm0b4p6Kmu",bCrlf); CkStringBuilderW_AppendLine(sb,L"Private-MAC: ef04289f158f498b8050e19f1630b4764fe64ab9",bCrlf); sshKey = CkSshKeyW_Create(); // Must specify a password for this PuTTY private key because it is encrypted. CkSshKeyW_putPassword(sshKey,L"secret"); success = CkSshKeyW_FromPuttyPrivateKey(sshKey,CkStringBuilderW_getAsString(sb)); if (success != TRUE) { wprintf(L"%s\n",CkSshKeyW_lastErrorText(sshKey)); wprintf(L"Failed.\n"); } wprintf(L"success = %d\n",success); CkStringBuilderW_Dispose(sb); CkSshKeyW_Dispose(sshKey); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.