Archived Forum PostQuestion:
Howdy,
I've had an SSH Tunnel Script working for a long time now as a 32-bit Chilkat app and it works well, but once I registered the 64-bit DLL for 9.5.0.58, it started throwing exceptions like this... (p.s. this looks like a bug in 9.5.0.58 x86 and x64)
C:scripts>cscript sshtunnel.vbs 192.168.0.133-rdp 192.168.0.107-rdp Microsoft (R) Windows Script Host Version 5.812 Copyright (C) Microsoft Corporation. All rights reserved.And then unregistering the x64 DLL and reregistering the x86 DLL worked like a charm (script worked as expected)... although the working 32-bit DLL is version 9.5.0.48.--->Tunnel will listen indefinitely <--- ---> Press Ctrl-C to shutdown the tunnel listener<---
192.168.0.133-rdp Found: 192.168.0.133-rdp 192.168.0.133:3389 on 22 Connecting through: xxx.xxx.xxx.xxx:22 Tested Tunnel parameters! ERROR WHILE TRYING TO START ACCEPTING: ChilkatLog: BeginAccepting: DllDate: Jun 13 2016 ChilkatVersion: 9.5.0.58 UnlockPrefix: CHANGEDFORPRIVACY Architecture: Little Endian; 64-bit Language: ActiveX / x64 VerboseLogging: 0 listenPort: 3333 dynamicPortForwarding: 0 StaticPortForwarding: destPort: 3389 destHostname: 192.168.0.107 --StaticPortForwarding Not yet connected to the SSH tunnel. Failed. --BeginAccepting --ChilkatLog
P.S. trying to make 9.5.0.58 32-bit DLL work, fails at same place.
ERROR WHILE TRYING TO START ACCEPTING:
ChilkatLog:
BeginAccepting:
DllDate: Jun 13 2016
ChilkatVersion: 9.5.0.58
UnlockPrefix: CHANGEDFORPRIVACY
Architecture: Little Endian; 32-bit
Language: ActiveX
VerboseLogging: 0
listenPort: 3333
dynamicPortForwarding: 0
StaticPortForwarding:
destPort: 3389
destHostname: 192.168.0.107
--StaticPortForwarding
Not yet connected to the SSH tunnel.
Failed.
--BeginAccepting
--ChilkatLog
For the time being, I'll just keep using the 32-bit 9.5.0.48 as I don't know where to download the x64 version from (only the current one [9.5.0.58] seems available). I am guessing this is a bug introduced after ".48".
Please let me know what you find, Steven
Here's my code... which was adapted from your samples
Function chillkat_establish_ssh_tunnel (sshTunnel,desthost,destport,throughhost,throughport,throughuser,throughpass,locallistenport)
On Error Resume Next
' The DestHostname may be the domain name or
' IP address (in dotted decimal notation) of the database
' server.
''we need to test that our tunnel will work first...
Set ssh = CreateObject("Chilkat_9_5_0.Ssh")
if Err.Number <> 0 Then
WScript.Echo " Error creating Object: " & Err.Description
chillkat_establish_ssh_tunnel = 0
Exit Function
End If
' Any string automatically begins a fully-functional 30-day trial.
success = ssh.UnlockComponent(ssh_unlock_code)
If (success <> 1) Then
WScript.Echo "error unlocking SSH with unlock code!"
chillkat_establish_ssh_tunnel = 0
Exit Function
End If
WScript.Echo "Connecting through: " & throughhost & ":" & throughport
success = ssh.Connect(throughhost,throughport)
If (success <> 1) Then
WScript.Echo " Error connecting to SSH through host in test: " & ssh.LastErrorText
chillkat_establish_ssh_tunnel = 0
Exit Function
End If
' Wait a max of 5 seconds when reading responses..
ssh.IdleTimeoutMs = 5000
success = ssh.AuthenticatePw(throughuser,throughpass)
If (success <> 1) Then
WScript.Echo " Error authenticating to SSH for ""through host"" in test: " & ssh.LastErrorText
chillkat_establish_ssh_tunnel = 0
Exit Function
End If
ssh.Disconnect
Err.Clear
WScript.Echo " Tested Tunnel parameters!"
sshTunnel.DestHostname = desthost
sshTunnel.DestPort = destport
sshTunnel.SshHostname = throughhost
sshTunnel.SshPort = throughport
sshTunnel.SshLogin = throughuser
sshTunnel.SshPassword = throughpass
success = sshTunnel.BeginAccepting(locallistenport)
If (success <> 1) Then
WScript.Echo " ERROR WHILE TRYING TO START ACCEPTING: "
WScript.Echo sshTunnel.LastErrorText
chillkat_establish_ssh_tunnel = 0
Exit Function
End If
chillkat_establish_ssh_tunnel = 1
End Function
With the flaw you are suggesting, the tunneling wouldn't work using 9.5.0.48.
While I do use SSH at the start (to test the credentials), you should notice that I switch over to the sshTunnel object which is a fully qualified 9.50 sshTunnel object. I'll be happy to give you the script in it's entirety, if you wish.. I just didn't want to overload the forum with the whole thing...
Here's the appropriate part of the function that creates the ssh object then closes it.. and moves on to the ssh tunnel object.
ssh.Disconnect
Err.Clear
WScript.Echo " Tested Tunnel parameters!"
sshTunnel.DestHostname = desthost
sshTunnel.DestPort = destport
sshTunnel.SshHostname = throughhost
sshTunnel.SshPort = throughport
sshTunnel.SshLogin = throughuser
sshTunnel.SshPassword = throughpass
success = sshTunnel.BeginAccepting(locallistenport)
Again.. This script totally works in 9.5.0.48... Did you change the functionality to require a Connect?
If you are suggesting I now NEED to use the connect function, I can.
Steven
HMMM... Score one for not looking at the newer release documentation. :(
https://www.chilkatsoft.com/refdoc/xChilkatSshTunnelRef.html
Apologies for thinking there was a bug..
“Connect was Introduced in 9.5.0.50”
I'll just quietly slink back to my corner of the Internet, and fix my code. :)
Steven
You're connecting using an Ssh object, which is not associated with the SshTunnel object in any way -- and therefore the connection is meaningless.
See this example: https://www.example-code.com/vbscript/sshTunnel_database.asp
The "Connect" call is on the SshTunnel object.