How can I Enter password automatically for an Script?
Hello.
How can I write an Script that enter my password for "sudo" command automatically? for example, I want to run a command that need root permission and when I write it in a bash script, it ask me "sudo" password for user but how can I automate it? Can it possible for other program like logging via SSH too? Thank you. |
you can add an entry to /etc/sudoers that will enable the user of the script to gain root privileges only for that command, without having to enter a password.
check out https://wiki.archlinux.org/index.php...xample_Entries if you're still stuck, show us what you got so far. |
If you don't want to change your sudo configuration, have a look at the Expect scripting language, which is designed exactly for this purpose.
|
Very insecure but if it's only run on your machine by you you can use
Code:
echo "mypassword"|sudo -S /path/to/command |
Quote:
I mean is that when I want connect to a system via SSH it put the username and password automatically and not ask me on the monitor. |
ssh is NOT sudo you are confusing two differernt commands that ask for two different passwords pleas epost the command you are tring to run.
|
My command is "SSH username@IP Address"
|
Use keys.
|
Quote:
Code:
man ssh |
Quote:
http://linuxconfig.org/passwordless-ssh |
All times are GMT -5. The time now is 02:55 PM. |