Im trying to use the SSH tool to be able to change a router ip via SSH, it is very simple via putty and port 22. We have a lot of the routers that we want to automate some of those configurations.
I've tried some of your examples but can't seem to get any to work. Below is just a basic test with a test box where I just want to see the interface information but it fails at couple of places where there is hostkey prompt that should indicate yes or no to accept the key but I don't see it . I have a form with button and the SshTerminalControl1 on it, Not sure what else I'm missing. I don't see any information in the terminal control either.
Imports ComponentPro.Net
Imports ComponentPro.Net.Terminal
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
HandleHostKeyVerifyingEvent()
End Sub
Public Sub HandleHostKeyVerifyingEvent()
Try
' Create a new instance.
Dim client As New SshClient()
' AddHandler client.HostKeyVerifying, AddressOf client_HostKeyVerifying
'Fails here
client.Connect("172.16.0.1", 22)
' Or you can specify the SFTP port with
' client.Connect("myserver", 22);
' Authenticate.
client.Authenticate("admin", "password")
' Do something here...
' ...
Dim shell As TerminalShell = client.CreateShell(True)
' Print any welcome messages, if available.
Console.WriteLine(shell.ReadToEnd())
' Send 'Showing the interface information' command.
shell.SendCommand("show interface x1")
Console.WriteLine(shell.ReadToEnd())
' Disconnect.
client.Disconnect()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Private Sub client_HostKeyVerifying(ByVal sender As Object, ByVal e As HostKeyVerifyingEventArgs)
' Print out the fingerprint info.
Console.Write(String.Format("Host key: {0}. Do you want to accept this host key?(y/n):", e.HostKey.ToString()))
Dim answer As String = Console.ReadLine()
' Accept the fingerprint if user entered "y".
e.Accept = answer.ToLower() = "y"
'Fails here saying something is null'
End Sub
End Class
The commands I want to send to the Router is in order below right after you would login is:
- interface x1
- ip-assignment WAN static
- ip
- netmask
- gateway
- dns primary
- commit
- exit
- exit
- exit
I need to translate these commands into your SSH tool via vb.net. If this all passes then I can move forward to purchasing your tool.
Thanks
edited 10/29/2018 4:16:20 PM
asked 10/26/2018 4:41:25 PM