LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 06-29-2010, 05:18 PM   #1
karlochacon
Member
 
Registered: Dec 2006
Posts: 107

Rep: Reputation: 17
insert password


hi guys

I have to create a script
where I have to su to another user and when that happens the pasword is requested as usual but since this script runs after hours no one can type the password so..I now it's not secure but is there a way to do this to have the password inserted automatically?
Code:
#!/bin/bash
su username
thanks a lot
 
Old 06-29-2010, 06:16 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora, Lubuntu, FreeBSD
Posts: 3,930
Blog Entries: 5

Rep: Reputation: Disabled
I believe you want sudo with some particular directives. Something like this would do the trick for foouser to be able to execute a couple commands as baruser:
Code:
foouser  ALL = (baruser) NOPASSWD: /some/command, /some/other/command
(That's off the top of my head. May or may not be syntactically correct.)

Be sure to read the sudo(8), visudo(8), and sudoers(5) manpages to get up and running.
 
Old 06-29-2010, 06:55 PM   #3
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,107

Rep: Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720
Quote:
Originally Posted by karlochacon View Post
hi guys

I have to create a script
where I have to su to another user and when that happens the pasword is requested as usual but since this script runs after hours no one can type the password so..I now it's not secure but is there a way to do this to have the password inserted automatically?
Code:
#!/bin/bash
su username
thanks a lot
You can use 'expect' to do it. Many examples on the web to help you along. However, I'd not do this, for a wide variety of reasons, security chief among them.

You provide no real details here (version/distro of Linux, how you're connecting, etc.), but if I had to do this, I'd use SSH, and do a key-swap between the two boxes. That way, the user can log in without having to key a password, and the connection would be safe. You could even pass the command/script to run on the command-line from CRON if you chose.
 
Old 06-29-2010, 07:17 PM   #4
karlochacon
Member
 
Registered: Dec 2006
Posts: 107

Original Poster
Rep: Reputation: 17
this is centos
 
Old 06-29-2010, 07:58 PM   #5
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,107

Rep: Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720
Quote:
Originally Posted by karlochacon View Post
this is centos
Ok...version?? How you're connecting?? etc??

Regardless, SSH is the best way to go.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GNOME: Gain privileges using current user's password instead of root's password maxkukartsev Fedora 5 02-10-2012 10:46 AM
[SOLVED] Installed newest Ubuntu setting a weak password. Changed password now buggered? lugoteehalt Ubuntu 1 05-29-2010 10:51 PM
insert lines into a file after calculating where to insert xonar Programming 13 12-24-2009 05:37 AM
simpler GUI password for Administrative tasks while retaining complex user password? workforfood Ubuntu 1 08-29-2009 07:48 AM
How to retrieve( or reset) root password in Mandrake Linux, as I forgot my password? Reghunath Linux - Software 4 05-08-2008 05:11 AM


All times are GMT -5. The time now is 11:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration