Secure CRT send command to an host VBS

1.4k views Asked by At

Hey i have tried to make a simple script that can log in and send commands to the host/server:

Sub Main 
    crt.Screen.Synchronous = True
    crt.Session.Connect "ip adress"
    crt.Screen.WaitForString "Username: "
    crt.Screen.Send "username" & chr(13)
    crt.Screen.WaitForString "Password: "
    crt.Screen.Send "password" & chr(13)
    crt.Screen.Send "?" & chr(13)
    crt.Screen.Synchronous = False
End Sub

my problem is it wont send anything.

1

There are 1 answers

0
Mikkel On BEST ANSWER

Its working now:

 Sub Main

  host = Array("host1", "host2")

  For each item in host

  Dim user
  user = "Username"


  Dim passwd
  passwd = "password"

  cmd = "/SSH2 /L " & user & " /PASSWORD " & passwd & " /C AES-192-CTR /M SHA2-256 " & item

  crt.Session.Connect cmd

  Dim tab, index, nTabCount

    nTabCount = crt.GetTabCount()

    for index = 1 to nTabCount
        set tab = crt.GetTab(index)
        tab.activate
        tab.screen.send "command" & vbcr
        crt.Sleep 5000
        crt.Session.Disconnect()
    next

  Next


End Sub