且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Windows上从plink.exe在Linux上执行sudo命令

更新时间:2023-12-04 09:56:34

我知道这个问题很旧,但是可以帮忙

i know that the question is old but this can help

您可以执行plink(putty工具)

you can execute plink (putty tools)

plink -v -ssh -m"path/to/commands.txt" -l usertologin -pw PASSWORDSERVER

commands.txt:

commands.txt:

echo -e"PASSWORD \ n" |须藤-S cat/etc/passwd

sudo -S用于接收来自stdin的密码,并使用echo -e"password \ n"用于传递密码(而\ n就像是按intro -new line-一样)

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- )

与执行passwd命令的方式相同:

the same way you can execute the passwd command:

> echo -e "OLDPASSWORD\nNEWPASSWORD\nNEWPASSWORD" | passwd