angelo massaro
angelo massaro

Reputation: 13

start plink-ssh connection from hta button and pass value to ssh command

I have a little problem with my HTA-vbs script.

This is my VBS script:

strInput = UserInput( "USER:" )
pswInput = UserInput( "PSW:" )

Function UserInput( myPrompt )
       UserInput = InputBox( myPrompt )
End Function

Set objShell = CreateObject("Wscript.Shell")

        objShell.Run "plink.exe &  [email protected] -pw PASSWORD -no-antispoof "myscript.sh"

So this is a simple vbs script that launch script in my linux remote machine (I launch this from HTA button). I need only that when I type user and password in a initial textbox, the script save the value and replace USER and PASSWORD when launch the ssh connection.

Is it possible?

Thank you so much. BYE! Angelo

Upvotes: 0

Views: 405

Answers (1)

Étienne Laneville
Étienne Laneville

Reputation: 5031

Something like this should work:

Dim sUserName
Dim sPassword
Dim objShell
Dim sCommand

sUserName = InputBox("USER:")
sPassword = InputBox("PSW:")

Set objShell = CreateObject("Wscript.Shell")

sCommand = "plink.exe " & sUserName & "@192.0.0.1 -pw " & sPassword & " -no-antispoof ""myscript.sh"""
objShell.Run sCommand

You don't need the UserInput function, you can call InputBox directly.

If you want to save the User Name and Password variables, there are ways to do that also, and you can have them be pre-populated in your InputBox:

' Set default values or perhaps read these from the Registry
sUserName = "admin"
sPassword = "password"

sUserName = InputBox("USER:", "Remote Connection", sUserName)
sPassword = InputBox("PSW:", "Remote Connection", sPassword)

Upvotes: 2

Related Questions