SQL Server
SQL Server
SSH Key Fingerprint
See more SSH Key Examples
Generates a fingerprint for an SSH key.Chilkat SQL Server Downloads
-- 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)
DECLARE @success int
SELECT @success = 0
DECLARE @key int
EXEC @hr = sp_OACreate 'Chilkat.SshKey', @key OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Load an SSH key from an encrypted OpenSSH-formatted private key:
EXEC sp_OASetProperty @key, 'Password', 'secret'
DECLARE @keyStr nvarchar(4000)
-- First load the PEM into a string:
EXEC sp_OAMethod @key, 'LoadText', @keyStr OUT, 'privkey_openssh_encrypted.pem'
-- Import into the SSH key object:
EXEC sp_OAMethod @key, 'FromOpenSshPrivateKey', @success OUT, @keyStr
IF @success <> 1
BEGIN
EXEC sp_OAGetProperty @key, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @key
RETURN
END
-- Generate the fingerprint:
DECLARE @fingerprint nvarchar(4000)
EXEC sp_OAMethod @key, 'GenFingerprint', @fingerprint OUT
PRINT @fingerprint
-- A sample fingerpring looks like this:
-- ssh-dss 2048 d0:5f:f7:d6:49:60:7b:50:19:f4:41:59:d4:1f:61:7
EXEC @hr = sp_OADestroy @key
END
GO