【发布时间】:2019-02-24 01:29:08
【问题描述】:
我目前正在设置一个批处理文件以从 Windows 机器 ssh 到 Ubuntu 机器并发出一系列命令。我正在使用 plink,并且我正在使用 -m 参数来传递带有命令列表的 .txt 文件。
贯穿cmd的批处理文件代码:
set PATH=c:\path\to\plink.exe
plink.exe -ssh -t user@ipaddress -pw <psw> -m c:\path\to\textFile\commands.txt
commands.txt 代码:
sudo -s #access the root login
<root psw> #enter the password for the root login
command-1 #issue a command in linux as root
command-2 #issue a command in linux as root
command-3 #issue a command in linux as root
我遇到的问题是,当我运行这个批处理文件时,命令提示符中的输出仍然提示用户手动输入密码。有没有办法从commands.txt 文件的下一行输入密码?还是这个过程需要别的东西?
【问题讨论】:
-
您可以考虑修改 Ubuntu 机器上的
/etc/sudoers文件以包含该用户的NOPASSWD。
标签: shell batch-file ssh sudo plink