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
(SQL Server) Load SSH Keys Produced by ssh-keygenDemonstrates how to load the public and private keys produced by ssh-keygen.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) -- This example assumes the Chilkat API to have been previously unlocked. -- See Global Unlock Sample for sample code. -- We first generate a key like this: -- ssh-keygen -f stg.chilkat.id -- Generating public/private rsa key pair. -- Enter passphrase (empty for no passphrase): -- Enter same passphrase again: -- Your identification has been saved in stg.chilkat.id. -- Your public key has been saved in stg.chilkat.id.pub. -- The key fingerprint is: -- SHA256:hkbgexkspxYTa8rYUxouRU8Gi7lbbsT6dSLX+JlStKk me@example02240 -- The key's randomart image is: -- +---[RSA 2048]----+ -- | o.= | -- | + * = | -- |o + X = | -- | O * O.+ | -- |+ @ +.=oS | -- | A o =+. | -- |o + =oo | -- | o +E+ o | -- | . .+ | -- +----[SHA256]-----+ -- -- The public key (generated to the file stg.chilkat.id.pub) contains this: -- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABA.. FDt+dKJEkhw8I7LpEi17diB9 me@example02240 -- First let's load the public key: DECLARE @pubkey int -- Use "Chilkat_9_5_0.SshKey" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.SshKey', @pubkey OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int EXEC sp_OAMethod @pubkey, 'LoadText', @sTmp0 OUT, 'qa_data/sshKeys/ssh-keygen/stg.chilkat.id.pub' EXEC sp_OAMethod @pubkey, 'FromOpenSshPublicKey', @success OUT, @sTmp0 IF @success = 0 BEGIN EXEC sp_OAGetProperty @pubkey, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @pubkey RETURN END EXEC sp_OAGetProperty @pubkey, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 PRINT 'Successfully loaded the public key.' -- Now try the private key, which contains this: -- -----BEGIN OPENSSH PRIVATE KEY----- -- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn -- NhAAAAAwEAAQAAAQEArNH9CpKhVgpGbOEDaFH4CaL9iQE6IwVYqKFkcF9qdHc6XA+J9PeR -- 9CMvTtVWm/uCYsoYzRkitNIEokjxFwyQwJeng+qWh5t538Ji3v64ls0mgsdvecyYDYjU8T -- mqhivXk/DzNBUOuyN5ksP0ZmRJLuZ4J6MKCrPugvKsE4zDQkg7/lKUL40ugjpoYJnhRjHv -- uogSkcecq6Kdw20WdRWTFvXiRH8mdh9cVWi3fvj0sly0CDghmuWyjvcrIOuixvy8kfADva -- tDAyF1se0r8WW9xZzUYHjuCzxbI+yfU3xS9/vX9T9IG10ocSbqrBgd/xQ7fnSiRJIcPCOy -- 6RIte3YgfQAAA9BXf/XaV3/12gAAAAdzc2gtcnNhAAABAQCs0f0KkqFWCkZs4QNoUfgJov -- 2JATojBViooWRwX2p0dzpcD4n095H0Iy9O1Vab+4JiyhjNGSK00gSiSPEXDJDAl6eD6paH -- m3nfwmLe/riWzSaCx295zJgNiNTxOaqGK9eT8PM0FQ67I3mSw/RmZEku5ngnowoKs+6C8q -- wTjMNCSDv+UpQvjS6COmhgmeFGMe+6iBKRx5yrop3DbRZ1FZMW9eJEfyZ2H1xVaLd++PSy -- XLQIOCGa5bKO9ysg66LG/LyR8AO9q0MDIXWx7SvxZb3FnNRgeO4LPFsj7J9TfFL3+9f1P0 -- gbXShxJuqsGB3/FDt+dKJEkhw8I7LpEi17diB9AAAAAwEAAQAAAQAPUtNAA75gdarG7rCx -- qEr498XJRx2Ti17QHPdd62fyCbxX+1y9JtJ/Njt0nv/99rAZ+Fd4oBjutYyJozQVWhzfpt -- LIpJ1SStvklkTUBvvxCyG2CN7+isCUuqQ++2D+YpbL3FqELLXQrBWUiOF7zrqaeP8AbLlw -- N4IXhFLzrNCHaODsbYAh8U1nOj1PvUO24quCzPRPH/LcERvgXeGEJSYoB0nwwKGppIpBnv -- jV5wvuhPdQVvN14e8SOodK76InfaGUsCUwr2ksaGhsTCGk7yCsyQUyzzV8InQ3CTPkLf9J -- BnBpymoyB/r3LnefX4AgKA7nplCRUANLbvTACTazHtcBAAAAgQCihdCPzywEkrn0VhYIOV -- sK7oIUD/EBEzb7yL+7naZqACStbhKiLKGgSJj2+3hgmQk2tZ94zN5lkCcLLFy9Ai47HkN+ -- dSmZqac5pQeVyWrJ/67OSqWxMFfjkbF/0IxXJM2y+i//vGWBDo3NJmkYGwY+XnFP81qqh9 -- boeQA0K6wn0wAAAIEA2tX2lZrwAyhl/L5XY1xsQ3uuoaIUeZD0vUs+mAv1pz8fbTAD2n37 -- Rh57mxDNQIwiD8lV5wZ20NP03nAr8gUQaijsBRy3gDXHX7Qa/BaJ2bY0492HXwVYi9bsng -- GJQinYjmJQQeR/w4u5rNzuD8y1ysMwh/sE8IGu6LLG1IBDYr0AAACBAMord/G9vderFO+1 -- tNZHl09m9mFLJTHRVH41Da2uCl2KJnYir511M9GSG9Un6L+UGu4F9CrypehgJHZ6QbwpgS -- JrwlCfE09jPkuH0aktg9fnrrEJYS30wWNNSj1v/91v1F3fdrZePd+UnKcP6zZB3jICzPhW -- elU1OYdWf+qFrnDBAAAAGWRqYWNrc29uMDIyQGRqYWNrc29uMDIyNDAB -- -----END OPENSSH PRIVATE KEY----- DECLARE @privkey int -- Use "Chilkat_9_5_0.SshKey" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.SshKey', @privkey OUT EXEC sp_OAMethod @pubkey, 'LoadText', @sTmp0 OUT, 'qa_data/sshKeys/ssh-keygen/stg.chilkat.id' EXEC sp_OAMethod @privkey, 'FromOpenSshPrivateKey', @success OUT, @sTmp0 IF @success = 0 BEGIN EXEC sp_OAGetProperty @privkey, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @pubkey EXEC @hr = sp_OADestroy @privkey RETURN END EXEC sp_OAGetProperty @privkey, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 PRINT 'Successfully loaded the private key.' EXEC @hr = sp_OADestroy @pubkey EXEC @hr = sp_OADestroy @privkey END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.