I'm trying to run commands in putty remotely & unfortunately i stuck on two problems.
Putty cli closed after running those commands.
I want sudo login remotely without prompt for password
Note: I already found solution for both problems & posting this question for future use.
First problem solution detail in here
Second problem solved by first two line of RemoteCommands.txt first line suggested here & after running that i run sudo -i
to do sudo login but it didn't prompt for password. so it solve accidentally.
VBScript.vbs
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Exec("C:\Putty\putty.exe -ssh <username>@<ip> -pw <password> -P <port> -m ""E:\putty\RemoteCommands.txt"" -t")
RemoteCommands.txt
sudo -S <<< "<password>" ls
sudo -i
/bin/bash
BatchFile.bat to run vbscript easily
@echo off
start cmd /k "cd /d E:\putty & cscript VBScript.vbs & exit"
Edited
To run commands after sudo login you can write something like this
sudo -i -- bash -c 'cmd1; cmd2'
or sudo -i -- bash -c 'cmd1 && cmd2'
I found this workaround from this link & with random tries. so i got no explanation about this :D ... if any one know detail about this please edit this answere & provide links
RemoteCommands.txt
sudo -S <<< "<password>" ls
sudo -i -- bash -c 'cd /home/shajji && npm start && /bin/bash'
/bin/bash