Results 1 to 8 of 8
Hi
I want to write a shell script for the following scenario.
when person wants to change the user, He/She types : su -
then system asks password.
I want ...
- 02-27-2009 #1Just Joined!
- Join Date
- Apr 2008
- Posts
- 4
Shell script
Hi
I want to write a shell script for the following scenario.
when person wants to change the user, He/She types : su -
then system asks password.
I want to automate in a way that "su -" command will automatically take password from my script.
can anybody tell me, if it is possible and how ??
Thanks a lot.
bye.
- 02-27-2009 #2
What are you trying to achieve?
Running su without a password for all commands is basically giving people administrator access... I would not recommend it at all - EXTREMELY insecure. Also, by putting the password in a file, you are also giving them root password as the script is probably going to need to be readable...
You can tie it down to a couple of commands that you want to run though. This would enable you to do something like 'let mary and joe run the shutdown command without a password', without giving them complete administrator privileges.
- 02-27-2009 #3Just Joined!
- Join Date
- Apr 2008
- Posts
- 4
I will only run that script for me.....
no access is allowed..
Is it possible.
- 02-27-2009 #4Linux Newbie
- Join Date
- Feb 2009
- Posts
- 99
mabye su can not use in script. try sudo. it's better.
- 02-27-2009 #5Just Joined!
- Join Date
- Apr 2008
- Posts
- 4
supppose this is the shell script:
#!/bin/sh
sudo su
When I will run it it wil ask me for password.
But I want to make it like that I can provide that "password" through my shell script.
Does any body knows, if it is possible?? if yes then how ??
- 02-27-2009 #6Linux Newbie
- Join Date
- Feb 2009
- Posts
- 99
you have to edit /etc/sudoer file
exmaple:
username ALL=(ALL) NOPASSWD: /sbin/mount /dev/cdrom /mnt
so your script can be write to:
#!/bin/bash
sudo /sbin/mount /dev/cdrom /mnt
and must be execute by username < - user.
- 02-27-2009 #7Just Joined!
- Join Date
- Apr 2008
- Posts
- 4
I want to write more scripts like this which asks for the different things from user.
and I want to make in that way it will do everything and automatically from the shell script.
- 02-28-2009 #8Linux Newbie
- Join Date
- Feb 2009
- Posts
- 99
try chown root script.sh ; chmod 1555 script.sh <- but dangerous.


Reply With Quote