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 11-22-2013, 05:52 AM   #1
nixque
LQ Newbie
 
Registered: Nov 2013
Posts: 5

Rep: Reputation: Disabled
Sudo password operator


Hi ! Is there a way to do sudo without being prompted for the pass after you pressed enter ?

sort of like ssh or mysql

ssh user@host -p password
mysql -u user -p pass

is there a sudo -p password ?

I want to do this because I want putty to autorun sudo -i when I log in to my server.

Thanks in advance

\Nixque
 
Old 11-22-2013, 05:59 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
There is no command line option to do this, but you can use NOPASSWD in the sudoers file.

These links might provide some info:
- HowTO: Sudoers Configuration
- Password Usage in Sudo (PASSWD / NOPASSWD)
 
1 members found this post helpful.
Old 11-22-2013, 06:00 AM   #3
lpwevers
Member
 
Registered: Apr 2005
Location: The Netherlands
Distribution: SuSE, CentOS
Posts: 143

Rep: Reputation: 20
Hi,

You can put the following in /etc/sudoers (using the visudo command):

Code:
User_Alias                        SYSMGT = <UID>
SYSMGT          HOST = (ALL)    NOPASSWD: ALL
That should do the trick I guess.
 
1 members found this post helpful.
Old 11-22-2013, 06:04 AM   #4
nixque
LQ Newbie
 
Registered: Nov 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by lpwevers View Post
Hi,

You can put the following in /etc/sudoers (using the visudo command):

Code:
User_Alias                        SYSMGT = <UID>
SYSMGT          HOST = (ALL)    NOPASSWD: ALL
That should do the trick I guess.
So if any user logs in and does the sudo command they don't need the password ?
That would make it kinda insecure
 
Old 11-22-2013, 06:17 AM   #5
lpwevers
Member
 
Registered: Apr 2005
Location: The Netherlands
Distribution: SuSE, CentOS
Posts: 143

Rep: Reputation: 20
Quote:
Originally Posted by nixque View Post
So if any user logs in and does the sudo command they don't need the password ?
That would make it kinda insecure
No, not any user. Just the users in the SYSMGT group.

So, for 2 users, it would look like this:
Code:
User_Alias                        SYSMGT = nixque, \
                                           lpwevers
SYSMGT          HOST = (ALL)    NOPASSWD: ALL

Last edited by lpwevers; 11-22-2013 at 06:19 AM. Reason: Added example
 
1 members found this post helpful.
Old 11-22-2013, 06:19 AM   #6
nixque
LQ Newbie
 
Registered: Nov 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by lpwevers View Post
No, not any user. Just the users in the SYSMGT group.
ok thanks for your help !
 
Old 11-22-2013, 06:20 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Quote:
Originally Posted by nixque View Post
So if any user logs in and does the sudo command they don't need the password ?
That would make it kinda insecure
NOPASSWD should be used wisely. Only use this option for specific commands and not for all commands that are run with sudo.

sudo -i runs a login shell and if I assume the shell is bash then something like this should work:
Code:
User_Alias UA_BASH  = username
Cmnd_Alias CA_BASH = /bin/bash
UA_BASH  ALL=(root)NOPASSWD: CA_BASH
username should be the user that is allowed to do this.

I'm not sure you want to do this: This user now has full root access, which isn't advisable.
 
1 members found this post helpful.
Old 11-22-2013, 06:27 AM   #8
nixque
LQ Newbie
 
Registered: Nov 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
isnt there another way to do it ?
sort of like this
sudo -i
echo mypassword
 
Old 11-22-2013, 06:34 AM   #9
r41d3n
Member
 
Registered: Mar 2013
Distribution: Debian
Posts: 42

Rep: Reputation: Disabled
You can read something about ssh keys. A good link explaining it is at https://wiki.archlinux.org/index.php/SSH_Keys

You can put a password in ~/.my.cnf file to login without need to type a password.
 
Old 11-22-2013, 06:37 AM   #10
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Quote:
Originally Posted by nixque View Post
isnt there another way to do it ?
sort of like this
sudo -i
echo mypassword
Assuming thet putty doesn't have an option to provide the password: Nope, the above examples given by me and lpwevers are the way to do this.

I'm not sure you use sudo in the correct way. Maybe using password-less ssh is a better option.

@r41d3n: ~/.my.cnf is a mysql specific file, not an ssh related file.

Last edited by druuna; 11-22-2013 at 06:38 AM.
 
Old 11-22-2013, 10:16 AM   #11
r41d3n
Member
 
Registered: Mar 2013
Distribution: Debian
Posts: 42

Rep: Reputation: Disabled
Quote:
@r41d3n: ~/.my.cnf is a mysql specific file, not an ssh related file.
Yes, you're right. I forgot to say that
 
  


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
No password for sudo? orange400 Linux - Software 9 03-18-2012 11:08 AM
sudo password not same as root password - ubuntu 11.04. hence can't access partitions daudiam Linux - Newbie 1 09-03-2011 12:02 PM
sudo password jbander Linux - General 4 02-17-2011 02:19 PM
my sudo password is not the root password newbiesforever Linux - General 7 01-02-2010 10:59 PM
Any reason user 'operator' is in the password file? LionKing Linux - Security 8 06-12-2001 09:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:09 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration