在Windows上从plink.exe在Linux上执行sudo命令 [英] Execute sudo command on Linux from plink.exe on Windows

查看:101
本文介绍了在Windows上从plink.exe在Linux上执行sudo命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我执行plink命令

If I execute the plink command

plink  user@192.168.1.12   sudo nano /etc/hosts

提示输入密码时,我得到了

Upon typing the password when prompted, I am getting

sudo:不存在tty且未指定AskPass程序

sudo: no tty present and no askpass program specified

对不起,再试一次.

sudo:不存在tty且未指定AskPass程序

sudo: no tty present and no askpass program specified

对不起,再试一次.

sudo:不存在tty且未指定AskPass程序

sudo: no tty present and no askpass program specified

对不起,再试一次.

sudo:3次不正确的密码尝试

sudo: 3 incorrect password attempts

如何从 plink 执行sudo 命令?还是有其他选择?

How to execute the sudo command from plink? Or is there any alternatives?

推荐答案

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

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

这篇关于在Windows上从plink.exe在Linux上执行sudo命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆