Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #####################
- |Calle's SSH script |
- | (.VB) |
- #####################
- Option Explicit
- ' Declare variables
- Dim objSsh
- ' Create SSh instance
- Set objSsh = CreateObject("ActiveXperts.Ssh")
- ' Write some information to console
- Wscript.Echo "ActiveSocket Version " & objSsh.Version & "; Build " & objSsh.Build & "; Module " & objSsh.Module
- WScript.Echo "Expiration date: " & objSsh.ExpirationDate & vbCrLf
- objSsh.Clear
- objSsh.Host = ReadInput( "127.0.0.1", False )
- objSsh.UserName = ReadInput( "root", False )
- objSsh.Password = ReadInput( "pw", True )
- objSsh.PrivateKeyFile = ReadInput( "", True )
- 'The next line accepts a changed or unknown host key
- objSsh.AcceptHostKey = true
- objSsh.Command = ReadInput( "Enter command:", "ls", False )
- objSsh.ScriptTimeOut = 5000
- objSsh.Run
- WScript.Echo "Run, result: " & objSsh.LastError & " (" & objSsh.GetErrorDescription( objSsh.LastError ) & ")"
- If objSsh.LastError = 0 Then
- WScript.Echo "StdOut: " & objSsh.StdOut
- WScript.Echo "StdErr: " & objSsh.StdErr
- End If
- WScript.Echo "Ready."
- ' ***************************************************************************
- ' Function ReadInput
- ' ***************************************************************************
- Function ReadInput( ByVal strTitle, ByVal strDefault, ByVal bAllowEmpty )
- Dim strInput, strReturn
- Do
- strInput = inputbox( strTitle, "Enter value", strDefault )
- If ( strInput <> "" ) Then
- strReturn = strInput
- End If
- Loop until strReturn <> "" Or bAllowEmpty
- ReadInput = strReturn
- End Function
Add Comment
Please, Sign In to add comment