I suspect su doesn't have any way to allow passing the password from the shell instead of being prompted for one, for security reasons (couldn't find anything in the MAN). Is this true?
Tell me more
×
Unix & Linux Stack Exchange is a question and answer site for
users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
|
|
|||
|
|
|
That's true, there is no way to have su(1) redirect its input from a place other than the tty. But there are libraries and programs to simulate a terminal for automated scripting, for example, Expect. Something similar to:
|
|||
|
|
|
It's an incredibly bad idea, but if you really want to do it you can use sudo's NOPASSWD option:
Then user johndoe can do I reiterate, though, that this is a REALLY BAD IDEA in most circumstances. Sudo, preferably /without/ the nopasswd flag is significantly safer. |
|||||||
|