?
Solved

Scipt file for a password.

Posted on 2003-03-10
5
Medium Priority
?
208 Views
Last Modified: 2012-05-04
Hi,

   Let's assume that there is a command that needs to be executed only by root. Is there a possibility that a script file can be used which will provide the password for the root. like :

su -c command
password : xxxxxxxx

this should happen without our entering the command.

is that possible? if yes how! and if no why?

-- Murthy.
0
Comment
Question by:snmurthy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Expert Comment

by:liormmm
ID: 8105452
Read sudo manual. You can restrict some user to run a certain command with root privileges. You can customize it to ask for a password or not.

If you have it installed, try visudo and you will be editing sudo configuration file.

Hope it helps.
0
 

Accepted Solution

by:
cspangen earned 80 total points
ID: 8105894
Yes, you can use a expect script file to supply the password to a root command. I have an example of the script below.

#!/usr/bin/expect --
stty -echo
log_user 0
spawn su
expect "Password:"
send "$password\r\n"
log_user 1
expect ">"
send "$command\r\n"
expect ">"

The $password variable needs to be substituted with the correct password, and the $command variable needs to be substituted with correct command to execute.

You can also use this other script to do the same thing.

#!/usr/bin/expect --
stty -echo
log_user 0
spawn su
expect "Password:"
send "$password\r\n"
log_user 1
expect ">"
send "$command\r\n"
expect ">"

There is security risks involved in puting a root password in a file. If a person can read the file then they can obtain the root password of the operating system.There are are solutions to that problem. If you need a secure solution let me know.

Carl
0
 
LVL 1

Expert Comment

by:-CrashOverride-
ID: 8106314
in root there is no password at first u login as root and ther is no passwor and if u wana make a password then you type in :
passw
and type in ur password
0
 

Expert Comment

by:CleanupPing
ID: 9087755
snmurthy:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 2

Expert Comment

by:TheWeakestLink
ID: 9287868
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept comments from cspangen as answer
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheWeakestLink
EE Cleanup Volunteer
0

Featured Post

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will giveā€¦
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question