Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

SQL Server Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text

HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(SQL Server) Use PuTTY Key for SSH Tunnel (PPK Private Key)

Demonstrates how to authenticate with a username + .ppk PuTTY private key w/ SSH Tunnel.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @tunnel int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.SshTunnel', @tunnel OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int
    EXEC sp_OAMethod @tunnel, 'UnlockComponent', @success OUT, 'Anything for 30-day trial.'
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @tunnel, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @tunnel
        RETURN
      END

    --  Load a .ppk PuTTY private key.
    DECLARE @puttyKey int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.SshKey', @puttyKey OUT

    DECLARE @ppkText nvarchar(4000)
    EXEC sp_OAMethod @puttyKey, 'LoadText', @ppkText OUT, 'qa_data/ppk/putty_private_secret.ppk'

    --  The ppkText contains this content:

    --  	PuTTY-User-Key-File-2: ssh-rsa
    --  	Encryption: aes256-cbc
    --  	Comment: rsa-key-20170126
    --  	Public-Lines: 6
    --  	AAAAB3NzaC1yc2EAAAABJQAAAQEAx+52s7vvaZ8rT2UdFZWlSUVDHDQ+5ZRFvgRW
    --  	6nm2sO1c9WqNg7u2PQL4jeKSDX2XWcMnpleALz2x8Rr4rMy5E1iZzvWov8VtFd8l
    --  	fa9HOkgEeJB3VFuYR3NlnD3eyCoYJYPVpHJHrIeui2WZs5vQ76HDe+th8+z5Ald4
    --  	zPw3p2c6ZJpBrkSBM67hWokoBDi23c7NhszDHhJBrv+B98cQxnagI1PUKqN7E8Vg
    --  	bNtBI8beIMHyI69up9G1AXSEi0cGIjYNx9RNUPau1mRk/SvfqxgWkAjM005lj7hc
    --  	bOsjbdKK3T2NtrKTaYjEiXlEXcj1iGuApsD/m73pYaEJB3Nd7w==
    --  	Private-Lines: 14
    --  	MoaDbq0owouN/7Z9Pga0favDhM2bSEgMErJBxdDmNUXIVVcUoLiD/Ps1RA+BeBBX
    --  	wxqKUt9PqLy/pnafPR/i2xjJiQtQ0CWkPxND16Gi1dqLzmbQYYl1ev4+LzuG0zNX
    --  	HDGMvRiwagY7mY+F1tUjBYfOL6z8XHw4m40YcY1QorOO+0MMzAVT5Hkg8YyXW209
    --  	B/V/LRADFMVA2BlL39y11cb5ZpFStPH/waYUMY+2w1ZmJZ7dcRoMjuKmY+YE/tUx
    --  	n9X3P0qTNSbw6e6sMG3Dhr1vfoJUQWApUliD6GpUiCeIvXBcVqG8Vsfq9XADsPl0
    --  	+nFAwjSZflywcB7/FwhGb7q5UmcJK06SzoMl7Og5e3g7NCs3yNNQIv+qCpDjhxrA
    --  	hpT03mbipu7OXCZDeUwUhMGJAmYHE5iqm1rPCsSVbaMgpxhCWf01Cx4gLx3aMvn4
    --  	MdylA31GuL3wSxcWTslrOI8+449lZN/qZEnGEZkYTrnlu123jTqsAWMMtuHSz2Ig
    --  	6GA89oTdlppkNflhNH3OJ85kMUrc3p/ZBMdndz8jTDTljmJjHR5oNMoShFof115A
    --  	nWjUHqBwCgcubLYyH3afDvBTOhtl0tJ9Oby0wJlOAGnCXiPSDbF/y7J7xml/PS9t
    --  	XlSVNxtAY15NDO6Fp96sBVfKuJsfJ90PzdBom4ikIuf7sMwtElrHHLuYfcXJQYLp
    --  	G5jBmqDgnirosVPEBIxlxFzz/HCRmdU+tsYg46gqI4R5UpKUe8WSaJoZkDGsrqhm
    --  	e+1SJaBuafR4v2bx/bV414Hg7LGQosK2S3crxH4UgZl+g02vWznZfBH+9CmHvKDR
    --  	AxfcKOTzsaILKJtQPV81lmJ45sARYMcB5jMiE4kBg56hiXouChsvKkm55WVcW1E+
    --  	Private-MAC: 17512c9f7582c1d9c3ae2b01b4d67a6b1dbd1d0e

    --  "secret" is the actual password for the above PPK.
    EXEC sp_OASetProperty @puttyKey, 'Password', 'secret'
    EXEC sp_OAMethod @puttyKey, 'FromPuttyPrivateKey', @success OUT, @ppkText
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @puttyKey, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @tunnel
        EXEC @hr = sp_OADestroy @puttyKey
        RETURN
      END

    DECLARE @sshHostname nvarchar(4000)
    SELECT @sshHostname = 'www.my-ssh-server.com'
    DECLARE @sshPort int
    SELECT @sshPort = 22

    --  Connect to an SSH server
    EXEC sp_OAMethod @tunnel, 'Connect', @success OUT, @sshHostname, @sshPort
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @tunnel, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @tunnel
        EXEC @hr = sp_OADestroy @puttyKey
        RETURN
      END

    --  Authenticate with the SSH server using a username + private key.
    --  (The private key serves as the password.  The username identifies
    --  the SSH user account on the server.)
    EXEC sp_OAMethod @tunnel, 'AuthenticatePk', @success OUT, 'mySshLogin', @puttyKey
    IF @success <> 1
      BEGIN
        EXEC sp_OAGetProperty @tunnel, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @tunnel
        EXEC @hr = sp_OADestroy @puttyKey
        RETURN
      END


    PRINT 'OK, the connection and authentication with the SSH server is completed.'

    --  This example is only to show the connection + authentication using a PuTTY private key...

    EXEC @hr = sp_OADestroy @tunnel
    EXEC @hr = sp_OADestroy @puttyKey


END
GO

 

© 2000-2019 Chilkat Software, Inc. All Rights Reserved.