How to pass the password to su/sudo/ssh without overriding the TTY?
问题 I'm writing a C Shell program that will be doing su or sudo or ssh . They all want their passwords in console input (the TTY) rather than stdin or the command line. Does anybody know a solution? Setting up password-less sudo is not an option. expect could be an option, but it's not present on my stripped-down system. 回答1: For sudo there is a -S option for accepting the password from standard input. Here is the man entry: -S The -S (stdin) option causes sudo to read the password from the