linux - [Solved-5 Solutions] How to pass the password to su/sudo/ssh without overriding the TTY - ubuntu - red hat - debian - linux server - linux pc
Linux - Problem :
How to pass the password to susudossh without overriding the TTY ?
Linux - Solution 1:
For sudo there is a -S option for accepting the password from standard input.
This will allow you to run a command like:
As for ssh, To automate/script it's usage with no success. There doesn't seem to be any build-in way to pass the password into the command without prompting. As others have mentioned, the "expect" utility seems like it is aimed at addressing this dilemma but ultimately, setting up the correct private-key authorization is the correct way to go when attempting to automate this.
Linux - Solution 2:
Applescript which prompts for a password through a dialog box and then builds a custom bash command, like this:
If sudo accepted a pre-encrypted password, so you could encrypt it within script and not worry about echoing clear text passwords around.
Linux - Solution 3:
For ssh you can use sshpass -p "password" ssh user@host sshpass works. You need to download sshpass firs
Linux - Solution 4:
Linux - Solution 5:
SSH can be used with private-public key authentication. If the private key does not have a passphrase, ssh can be used without prompting for a password.