如何在不覆盖TTY的情况下将密码传递给su/sudo/ssh?我正在编写一个C Shell程序su或sudo或ssh..他们都希望自己的密码在控制台输入(TTY),而不是stdin或命令行。有人知道解决办法吗?设置无密码sudo不是一种选择。期待可能是一种选择,但在我的精简系统中不存在。
3 回答

开心每一天1111
TA贡献1836条经验 获得超13个赞
-S The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device.
echo myPassword | sudo -S ls /tmp

慕哥9229398
TA贡献1877条经验 获得超6个赞
echo <password> | sudo -S <command>

GCT1015
TA贡献1827条经验 获得超4个赞
echo <password> | sudo -S <command>
- 3 回答
- 0 关注
- 602 浏览
添加回答
举报
0/150
提交
取消