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

jeck猫
TA贡献1909条经验 获得超7个赞
-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

素胚勾勒不出你
TA贡献1827条经验 获得超9个赞
echo <password> | sudo -S <command>

德玛西亚99
TA贡献1770条经验 获得超3个赞
ssh-keygen Enter file in which to save the key (/home/myuser/.ssh/id_rsa): <Hit enter for default> Overwrite (y/n)? y
ssh-copy-id <remote_user>@<other_host> remote_user@other_host's password: <Enter remote user's password here>
ssh remote_user@other_host
- 3 回答
- 0 关注
- 861 浏览
添加回答
举报
0/150
提交
取消