Reputation: 11
I have a code by which I open plink
for SSH connection using shell command where I can run any command by StdIn.Writeline
method except password change command. If I run a change password command I am unable to input the password by StdIn.Writeline
method. The command is like set usr pwd
. This command gets executed perfectly and after it executes it asks for "Enter Current Password". Here the WriteLine
method fails to input the password.
Below is the example of the code and ouput:
Run = filename & " " & strCompAddress & " -P " & strServerPOrt & " -l " & strServerUser & " -pw " & strServerPassword
Set osh = CreateObject("Wscript.Shell")
Set oEx = osh.exec(Run)
oEx.StdIn.WriteLine "command 1" 'This command runs fine'
oEx.StdIn.WriteLine "command 2" 'This command runs fine'
oEx.StdIn.WriteLine "command 3" 'This command runs fine'
oEx.StdIn.WriteLine "set usr wd" 'This command runs fine'
oEx.StdIn.WriteLine "current_pwd" 'This doesn't input the password and it stucks here
oEx.StdIn.WriteLine "new_pwd"
oEx.StdIn.WriteLine "new_pwd"
oEx.StdIn.WriteLine "exit"
Output is like with lots of escape sequence commands.
command 1 command 2 command 3 set usr pwd current_pwd new_pwd new_pwd exit Command 1 result ok command 2 result ok command 3 result ok set usr pwd Enter Current Password:
Upvotes: 1
Views: 264
Reputation: 202474
The command set user password
(or whatever it is) is possibly built to read the password from terminal only, not from a standard input. This is a common security feature to avoid exactly this kind of automatic password change.
Try forcing an interactive/terminal mode using the Plink command-line switch -t
.
This will make the Plink input be redirected to a virtual terminal and can make your command happy.
Make sure the server admin is happy with, what you are trying to do.
Upvotes: 2