Objective-C
Objective-C
Load PuTTY Private Key
See more SSH Key Examples
Loads a PuTTY private key into an SSH key object.Chilkat Objective-C Downloads
#import <CkoStringBuilder.h>
#import <CkoSshKey.h>
BOOL success = NO;
CkoStringBuilder *sb = [[CkoStringBuilder alloc] init];
BOOL bCrlf = YES;
[sb AppendLine: @"PuTTY-User-Key-File-2: ssh-rsa" crlf: bCrlf];
[sb AppendLine: @"Encryption: aes256-cbc" crlf: bCrlf];
[sb AppendLine: @"Comment: rsa-key-20161121" crlf: bCrlf];
[sb AppendLine: @"Public-Lines: 6" crlf: bCrlf];
[sb AppendLine: @"AAAAB3NzaC1yc2EAAAABJQAAAQEArIVxZTGYjqqNegJeMqgZzXKuX3YtxmD4DPnQ" crlf: bCrlf];
[sb AppendLine: @"K01SXoR9UA4wl6RJK5FGonI5spVnddr6HJny0eY5/RmV1dyL0fNdH2pfnHHoTd9B" crlf: bCrlf];
[sb AppendLine: @"uXG0PcTn4BqJFlybC6NNaGaByqpNPaOgjJIMHXTaeCuDuzwP02f3UKSfLAFdvUNP" crlf: bCrlf];
[sb AppendLine: @"fX3yrMRabjVcHJpgUn535Y9Y3ZphSFssiElLpp1vo6QLsdiAl0wgU4HLw9Dfg8sh" crlf: bCrlf];
[sb AppendLine: @"p3zgAufYUUIx2HChITJ7OO/PH5GEbPvJFbYH4Wx33GEe56JCF9QxxDCqNxsPMrvu" crlf: bCrlf];
[sb AppendLine: @"mqkSIPIELFl5zVYSFD9PiL8RZQcPJGq5zbF9+szsS/6DSH8biw==" crlf: bCrlf];
[sb AppendLine: @"Private-Lines: 14" crlf: bCrlf];
[sb AppendLine: @"SVqUm9zBUN6zaAaUY6TLnIXAhxqv4s1UhzukcN7Ns0Fs1EqdDP4nVMKgmiDxHaAj" crlf: bCrlf];
[sb AppendLine: @"ucb1PLv7uj2eGt69E+HKH4AC2LtJZNH4qLw+p8QKqdN79oRAMHwtS4cU88eeQ91t" crlf: bCrlf];
[sb AppendLine: @"2W3wzmTzvYFlE6VbUr3bNl3f68OCQHz+7YJuL8g0eclNuveHB/VmBqnek1LL/cRY" crlf: bCrlf];
[sb AppendLine: @"wmk8wyzHRl7X8fyjGX0PiOPyVwXBDJFNjjKAdrRCRS0Cc4PWAb/18qrA9ApArQVk" crlf: bCrlf];
[sb AppendLine: @"a5miOMfrXFF2Vg3JyNgfdDilNKkry9x5oTtfueZkFgu/6pofP5qrTstr+BmB16mu" crlf: bCrlf];
[sb AppendLine: @"MxcDRF+jOm9XvU1OnrzQ9rBzuaHEfhSHqlKyMGTDuzRtNyxlDBgK4DaZ2z1FJQGF" crlf: bCrlf];
[sb AppendLine: @"63p36KgVqx571PUJ8P/28VUb6s/OtXcjhxxvhC8Eo0wrTdjzDiX+IovdjOhWgn4v" crlf: bCrlf];
[sb AppendLine: @"xugaYocotTbhqq+O1w9xYtmG8fP921+TIpHzCkE8QTJzLJ40pemKZ+TAOmhb0OUQ" crlf: bCrlf];
[sb AppendLine: @"jemqmRohcxx7NEoZ0TsoAe6i+GQJ2cEE7LcNcSX3V66AkyTsTieqk1nSxyHyoF+l" crlf: bCrlf];
[sb AppendLine: @"rTaVOhFM5H8Etzv94SP3c1if3Qa9cmZaEmfaqrS94bzX+OY/zRIFweT0BeMo3Uac" crlf: bCrlf];
[sb AppendLine: @"fP6gBDBiLYZeRURcx0mYRdNYlssaKoYLA6c7F3ggo34VfgD6LP+ZYnG8yAXGXSPr" crlf: bCrlf];
[sb AppendLine: @"lgrfdg/szqSsOKVdkoGTkVy+BgrhITnFIs8TLZsrtSEPmXjEa+QvdP6FPsyN5u6P" crlf: bCrlf];
[sb AppendLine: @"8s0i8EC0KT0YA77Ps29DEU3fxsXVSc9Xd9qdiWfJ0ce2hOsTwxL1gxtXUKP4xCzm" crlf: bCrlf];
[sb AppendLine: @"oXaWLFajiws2EjgBbwREj12v0I2N4xrpf/PeJq22EvWLYm9H94DdFrkm0b4p6Kmu" crlf: bCrlf];
[sb AppendLine: @"Private-MAC: ef04289f158f498b8050e19f1630b4764fe64ab9" crlf: bCrlf];
CkoSshKey *sshKey = [[CkoSshKey alloc] init];
// Must specify a password for this PuTTY private key because it is encrypted.
sshKey.Password = @"secret";
success = [sshKey FromPuttyPrivateKey: [sb GetAsString]];
if (success != YES) {
NSLog(@"%@",sshKey.LastErrorText);
NSLog(@"%@",@"Failed.");
}
NSLog(@"%@%d",@"success = ",success);