Results 1 to 7 of 7
Hello!
Is it possible to run a program (with root permissions via shell script) without typing a password?
For example in the shell script, maybe there could be something like:
...
- 06-13-2009 #1Just Joined!
- Join Date
- Jun 2009
- Posts
- 44
[SOLVED] Easy question
Hello!
Is it possible to run a program (with root permissions via shell script) without typing a password?
For example in the shell script, maybe there could be something like:
exec su -c $myprogram -p:MYPASSWORD001 #the bold part is made up
If it's not possible, can I send the password in the shell script through some SEND_KEYSTROKES equivalent command?
Thank you.
ADFC
- 06-13-2009 #2
You might be able to pipe the data(password) to the su command via a script...But this leaves the root password available in a script...G4143
I'm not really sure what your after here????Make mine Arch Linux
- 06-13-2009 #3Just Joined!
- Join Date
- Jun 2009
- Posts
- 44
I don't mind!
I just don't want to type the password.
I want it to be transmitted automatically to su (via script).
That way, I don't need to type it repeatedly (since I will provide the correct password in the shell script).
I don't care about security. Consider it an exercise.
Thank you
- 06-13-2009 #4Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
Try sudo instead. First check if you have it installed. You should have its configuration file /etc/sudoers if you do.
1. Edit that file by using command visudo, append this line to the file:
yourusername ALL=NOPASSWD:/path/to/myprogram
2. Save the file then run
myprogram should run without asking you for password.Code:sudo /path/to/myprogram
- 06-13-2009 #5Just Joined!
- Join Date
- Jun 2009
- Posts
- 44
Hello!
I don't have sudo.
I can't install sudo either.
I have a multitude of computers that need to run a specific program (with root permissions) every day.
I can't make any modifications/additions to any of the installed files in the HDD.
But I have to automate the process as much as I can (since I run this program in many PCs per day).
So preferably, my solution would be programatical (via script).
After the script is executed, it will be deleted (that's why I said I didn't care about the root's pass being exposed).
Something equivalent to the VisualBasic SendKeys function would be nice.
But in Bash...
Ideas?
Thank you.
- 06-13-2009 #6Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
Try passwordless ssh login on the local machine: [ assuming you have ssh server running ]
1. suppose your username is testuser
2. as testuser, run
accept the default options for the questionsCode:ssh-genkey -t rsa
3.as root
4. exit back to testuser, runCode:cat /home/testuser/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys2
to test if passwordless login is working. It might ask you if you want to connect if this is the first time you run this command. Answer yes, after that it should not ask you for password and you are now ssh to the localhost as root.Code:ssh root@localhost
5. exit
6. Now run your program:
For more info on passwordless ssh, please read ssh-keygen: password-less SSH loginCode:ssh root@localhost /path/to/myprogram
I should warn you that there is a huge security risk in this approach since anyone having access to testuser's home dir can gain root access easily.
- 07-02-2009 #7Just Joined!
- Join Date
- Jun 2009
- Posts
- 44
Hello secondmouse!
I ended up following the above suggestion (I'm sorry, I did have sudo installed after all).
I temporarily modify (via script) the sudoers file and in the end, the file is reverted back to it's original content.
That way, I don't modify anything in the HDD, and I get temporary access to the programs I want to run.
Thank you all.
ADFC
SOLVED



