如何在不覆蓋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 關注
- 896 瀏覽
添加回答
舉報
0/150
提交
取消