LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-21-2006, 01:00 PM   #1
DejaCpp
LQ Newbie
 
Registered: Jul 2006
Posts: 7

Rep: Reputation: 0
Prevent user account from logging in but allow su to account


I would like to create an account called general that no one can login to. The only way to get to the genearl account would be to su to the account. Is it possible to do this. Thanks.

DejaCpp...
 
Old 07-21-2006, 04:15 PM   #2
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
I don't think you can do this and still allow access via "su", but I know you can do it and allow access via "sudo". sudo is better for what you want anyway, IMHO.

(1) Create a "passwordless account". Thus, nobody can login to the account directly. This example creates a group "gengroup" and then a userid of "general" that is in this newly created group "gengroup". HOME directory of /home/general, default shell of /bin/bash. Note: there is no -p option given to useradd, so the login is created in a disabled state.
Code:
$ su
# groupadd gengroup
# useradd \
   -c "General login" \
   -d /home/general \
   -m \
   -g gengroup \
   -s /bin/bash
   general
#
(2) Allow existing userid "fred" sudo access to the new login "general".
Code:
$ su
# sudoedit /etc/sudoers

  add the following line: "fred ALL = /usr/bin/su general"
#
Userid "fred" can now access "general" like this:
Code:
$ whoami
fred
$ sudo su - general
$ whoami
general
$
Fred will be prompted for a password - the password entered needs to be fred's, not general's (since general does not even HAVE a password!)

If you want fred to be able to access general WITHOUT entering any passwords, change the /etc/sudoers file entry like this:
Code:
$ su
# sudoedit /etc/sudoers

  change that previously created line to: "fred ALL = NOPASSWD: /usr/bin/su general"

Last edited by haertig; 07-21-2006 at 04:32 PM.
 
Old 07-21-2006, 06:24 PM   #3
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Or, just set the account's shell to /bin/nologin or similar and then run 'su -s /bin/bash USERNAME' to SU to the account.
 
Old 07-26-2006, 11:43 AM   #4
DejaCpp
LQ Newbie
 
Registered: Jul 2006
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks to both of your for helping me solve my problem. I am new to Linux. I have been using Windows forever. I am not a full convert yet but I am start to get use to it. Again thanks for your help. DejaCpp sends...
 
Old 07-26-2006, 11:44 AM   #5
DejaCpp
LQ Newbie
 
Registered: Jul 2006
Posts: 7

Original Poster
Rep: Reputation: 0
...starting....
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
User Account to Access Another Account benfaust Linux - General 2 06-28-2006 12:26 PM
system account or user account??? yenonn Linux - Newbie 6 05-10-2006 07:49 PM
is it legitimate and allowed and can be done to make another user account set uid and gid to null 0 to make another root account with different name and possibly not damage the debian system creating and using that new account BenJoBoy Linux - Newbie 12 01-29-2006 10:02 AM
Logging account lockout sbrewer Linux - Security 1 10-22-2005 03:48 PM
error logging into user account ambelos Linux - Laptop and Netbook 2 01-22-2004 08:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:30 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
Open Source Consulting | Domain Registration