If I execute the plink command
plink [email protected] sudo nano /etc/hosts
Upon typing the password when prompted, I am getting
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry,try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: 3 incorrect password attempts
How to execute the sudo command
from plink
? Or is there any alternatives?
There is no sudo command in Windows. The nearest equivalent is "run as administrator." You can do this using the runas command with an administrator trust-level, or by right-clicking the program in the UI and choosing "run as administrator."
1 Using Plink for interactive logins. To make a simple interactive connection to a remote server, just type plink and then the host name: Z:\sysosd>plink login.example.com Debian GNU/Linux 2.2 flunky.example.com flunky login: You should then be able to log in as normal and run a session.
Plink is a command line application. This means that you cannot just double-click on its icon to run it and instead you have to bring up a console window. In Windows 95, 98, and ME, this is called an 'MS-DOS Prompt', and in Windows NT, 2000, and XP, it is called a 'Command Prompt'.
Running a Specific Script as Another User. Before we can execute scripts as other users with sudo, we'll need to add the current user to the sudoers file. To do that, we'll use the visudo command to safely edit the /etc/sudoers file. The command above echo the rule and pipe the rule into the visudo command.
i know that the question is old but this can help
you can execute plink (putty tools)
plink -v -ssh -m "path/to/commands.txt" -l usertologin -pw PASSWORDSERVER
commands.txt:
echo -e "PASSWORD\n" | sudo -S cat /etc/passwd
sudo -S is to receive the password from stdin and with the echo -e "password\n" is to pass the password (and \n is like to press intro -new line- )
the same way you can execute the passwd command:
> echo -e "OLDPASSWORD\nNEWPASSWORD\nNEWPASSWORD" | passwd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With