Sample code for 30+ languages & platforms
Classic ASP

Authenticate an SSH Tunnel with a Private Key

See more Socket/SSL/TLS Examples

Demonstrates Socket.SshAuthenticatePk, which authenticates an SSH tunnel session using a private key loaded into an SshKey object. Call SshOpenTunnel first.

The file path is relative to the application's current working directory. An absolute path may also be used. Supply the path appropriate to your own environment.

Background. The SSH server must have the corresponding public key authorized for the account. If the private key is encrypted, set the SshKey.Password property before loading it.

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

set socket = Server.CreateObject("Chilkat.Socket")

success = socket.SshOpenTunnel("ssh.example.com",22)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( socket.LastErrorText) & "</pre>"
    Response.End
End If

'  Load the SSH private key.  The file path is relative to the application's current working
'  directory.  If the key is encrypted, set the SshKey.Password property before calling
'  FromOpenSshPrivateKey.
set sshKey = Server.CreateObject("Chilkat.SshKey")
keyText = sshKey.LoadText("qa_data/id_ed25519")
If (sshKey.LastMethodSuccess = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( sshKey.LastErrorText) & "</pre>"
    Response.End
End If

success = sshKey.FromOpenSshPrivateKey(keyText)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( sshKey.LastErrorText) & "</pre>"
    Response.End
End If

'  Authenticate the SSH tunnel session using public-key authentication.  The SSH server must have the
'  corresponding public key authorized for the account.
success = socket.SshAuthenticatePk("sshUser",sshKey)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( socket.LastErrorText) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "SSH public-key authentication succeeded.") & "</pre>"

%>
</body>
</html>