I got it now working, using the Chilkat ActiveX Control. For my tests i have a Windows with a TextArea, a Thread, a Timer, a few Properties and 3 PushButtons.
The first Button opens the connection:
[code] ssh.DebugLogFilePath = f.NativePath
Dim cmdOutput As String
success = ssh.UnlockComponent(“Anything for 30-day trial”)
If (success <> 1) Then
TextArea1.AppendText ssh.LastErrorText + EndOfLine + " >>>>>>>>>>>>>>>>>>>>>>>>>> " + EndOfLine
'Quit
Else
TextArea1.AppendText “SSH Plugin registered…” + EndOfLine
End If
success = ssh.Connect(myIPAdress,22)
If (success <> 1) Then
MsgBox ssh.LastErrorText
Quit
Else
TextArea1.AppendText “Connected…” + EndOfLine
End If
// Wait a max of 5 seconds when reading responses…
ssh.IdleTimeoutMs = 5000
ssh.VerboseLogging = 1
// Authenticate using login/password:
success = ssh.AuthenticatePw(myLogin,myPassword
If (success <> 1) Then
MsgBox ssh.LastErrorText
Quit
Else
TextArea1.AppendText “Logged in…” + EndOfLine
End If
// Open a session channel. (It is possible to have multiple
// session channels open simultaneously.)
channelNum = ssh.OpenSessionChannel()
If (channelNum < 0) Then
TextArea1.AppendText ssh.LastErrorText + EndOfLine + " >>>>>>>>>>>>>>>>>>>>>>>>>> " + EndOfLine
'Quit
Else
TextArea1.AppendText “Channel opened…” + EndOfLine
End If
’ Some SSH servers require a pseudo-terminal
’ If so, include the call to SendReqPty. If not, then
’ comment out the call to SendReqPty.
’ Note: The 2nd argument of SendReqPty is the terminal type,
’ which should be something like “xterm”, “vt100”, “dumb”, etc.
’ A “dumb” terminal is one that cannot process escape sequences.
’ Smart terminals, such as “xterm”, “vt100”, etc. process
’ escape sequences. If you select a type of smart terminal,
’ your application will receive these escape sequences
’ included in the command’s output. Use “dumb” if you do not
’ want to receive escape sequences. (Assuming your SSH
’ server recognizes “dumb” as a standard dumb terminal.)
Dim termType As String
termType = “dumb”
Dim widthInChars As Integer
widthInChars = 120
Dim heightInChars As Integer
heightInChars = 40
’ Use 0 for pixWidth and pixHeight when the dimensions
’ are set in number-of-chars.
Dim pixWidth As Integer
pixWidth = 0
Dim pixHeight As Integer
pixHeight = 0
success = ssh.SendReqPty(channelNum,termType,widthInChars,heightInChars,pixWidth,pixHeight)
If (success <> 1) Then
TextArea1.AppendText ssh.LastErrorText + EndOfLine
Else
TextArea1.AppendText “Terminal started…” + EndOfLine
End If
’ Start a shell on the channel:
success = ssh.SendReqShell(channelNum)
If (success <> 1) Then
TextArea1.AppendText ssh.LastErrorText + EndOfLine
Else
TextArea1.AppendText “Session opened…” + EndOfLine
End If[/code]
The 2nd Button sends a command:
[code] ’ Start a command in the remote shell. This example
’ will send a “ls” command to retrieve the directory listing.
success = ssh.ChannelSendString(channelNum,“show xdsl operational-data line 1/1/1/1 xml” + EndOfLine.UNIX,“utf-8”)
If (success <> 1) Then
MsgBox ssh.LastErrorText
End If
’ Send an EOF. This tells the server that no more data will
’ be sent on this channel. The channel remains open, and
’ the SSH client may still receive output on this channel.
// success = ssh.ChannelSendEof(channelNum)
// If (success <> 1) Then
// MsgBox ssh.LastErrorText
// End If
Thread1.Run[/code]
Then i pull the received server response in a Thread:
[code] WeitereDaten = ssh.ChannelReadAndPoll(channelNum,2000)
If WeitereDaten > -1 Then
Timer1.Mode = 2
While WeitereDaten >0
If ssh<>Nil Then
cmdOutput = ssh.GetReceivedText(channelNum,“utf-8”)
If cmdOutput <> “” Then
DerText = DerText + cmdOutput
End If
End If
Wend
End If
Me.Kill[/code]
In a Timer, i write the received server response to the TextArea:
[code] If Thread1<>Nil Then
TextArea1.AppendText DerText
Me.Mode = 0
DerText = ""
End If[/code]
The 3rd Button just disconnects:
' Disconnect
Timer1.Mode = 0
ssh.Disconnect
TextArea1.AppendText "Disconnected" + EndOfLine
This “example” is far from beeing well done, but it shows how to make it work (essentially).
But i would still prefer a solution which is cross plattform and which would avoid paying for an ActiveX Control…