LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 01-18-2006, 12:19 AM   #1
doronunu
Member
 
Registered: Dec 2005
Location: Israel
Distribution: used : Ubuntu, Debian, Arch. current : Centos.
Posts: 69

Rep: Reputation: 15
useradd -D


when i write useradd -D i get in the shell argument /bin/bash

Quote:
$ useradd -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
i know how to change it (useradd -D -s the_shell_name)
but how can i erase it, make it empty?
 
Old 01-18-2006, 01:28 AM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 13.37
Posts: 4,021

Rep: Reputation: 125Reputation: 125
If you have root access you can edit /etc/passwd and remove the shell name from after the last colon. Also, systems like Slackware have a usermod command that you can use - try `man usermod` for details.
 
Old 01-18-2006, 02:36 AM   #3
doronunu
Member
 
Registered: Dec 2005
Location: Israel
Distribution: used : Ubuntu, Debian, Arch. current : Centos.
Posts: 69

Original Poster
Rep: Reputation: 15
i know that but i want to do it with out configuring any file.
but i want to change the default and not to change a file every time im adding a user.
 
Old 01-18-2006, 02:43 AM   #4
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 59
The default settings are usually taken from files in /etc/skel (short for skeleton) or something.
All that the -D option does is modify those skeleton (template if you will) files. The next time you'll
add a user, the changes by -D will be read from the modified skel files.

So, my suggestion is:
-check out where your skeleton files are located (try "man useradd")
-modify those once (as root).
After that, all your new user should have the settings you want.

Just maybe, useradd -D -s '' or something will work too.

I must say that it's not very clear to me why you want empty shells. This will probably only result in errors. If you want to deny shell logins to certain users, try using /etc/nologin or /bin/false or something as shell (depends somewhat on your system). See "man nologin".
 
Old 01-18-2006, 03:44 AM   #5
doronunu
Member
 
Registered: Dec 2005
Location: Israel
Distribution: used : Ubuntu, Debian, Arch. current : Centos.
Posts: 69

Original Poster
Rep: Reputation: 15
actually i dont want to change the shell to empty, it was just an example, i could asked about any of the arguments. i just wanted to learn how to do that cos i know how to add or modify one of the argument in the useradd -D but didnt knew how to delete. now i know, 10x.
 
Old 01-18-2006, 04:01 AM   #6
ajs318
LQ Newbie
 
Registered: Apr 2004
Location: East Midlands
Distribution: Debian SID; Mandrake
Posts: 17

Rep: Reputation: 0
Don't set the user's shell to be empty if you don't want them having a login shell. Set it to /bin/false {/bin/true also works and I think it is slightly more amusing}.

If you want a user to be able to connect by FTP but not have shell login access, then add a line reading /bin/false to the file /etc/shells.
 
Old 01-18-2006, 06:50 AM   #7
doronunu
Member
 
Registered: Dec 2005
Location: Israel
Distribution: used : Ubuntu, Debian, Arch. current : Centos.
Posts: 69

Original Poster
Rep: Reputation: 15
my FTP server reason my first tough why i dont want users able to be connect with shells by default.
i want to make a scrip to my FTP server for opening users on him but i dont want them to having a shell.
whats the different if its false or none?
 
Old 01-18-2006, 07:48 AM   #8
ajs318
LQ Newbie
 
Registered: Apr 2004
Location: East Midlands
Distribution: Debian SID; Mandrake
Posts: 17

Rep: Reputation: 0
no shell

If you leave the shell field blank for a user, behaviour is undefined whenm that user tries to log in. You'll have to look at the source code of the "login" command {available from your distribution's web site} to figure out what will happen. It should specify a program which does something; ideally interpret commands.

The purpose of /etc/shells is to give ProFTPD a hint as to which users to let in, based on their default shell in /etc/passwd. I use /bin/bash for a "normal" user, /bin/false {which is in /etc/shells} for an "email and FTP only" user and /bin/true {which is not in /etc/shells} for an "email only" user.

/bin/false is just a little program that swallows any input from STDIN, and exits without generating any output on STDOUT or error messages on STDERR -- just a "not OK" error code. /bin/true is similar, but exits with an "OK" code. {The login program behaves a little differently depending whether the last "shell" it launched exited cleanly or not; I think the true one is a bit funnier but that's just my warped sense of humour.} The original usage of these programs was in shell scripts, where "false" or "true" could be used for testing complex conditional expressions. Bash actually has "true" and "false" as built-in commands; but older command shells didn't, so they have to stay around just in case.

Assuming you have the bsdgames package installed, try something like
Code:
# useradd -gusers -p! -m -s/usr/games/adventure somebody
# passwd somebody
Now go to another virtual console {ctrl + alt + f1-f6} and login as "somebody" with the password you just gave ..... and you should find that you go straight into a game of adventure.
 
Old 01-18-2006, 10:03 AM   #9
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 59
If you have it, using the "nologin" program is actually better than the "false" or "true" programs.
"nologin" is especially provided to disallow logins, so it's simply better suited for the job.

As for having FTP users without a real login, you should consider using "virtual users". Most modern FTP daemons, like vsftpd - and probably also proftpd - support this feature.
Simply said, you create a database of ftp users that don't have real logins (no real users, so they're called
virtual users) and you allow users access to FTP if they have a login in that database.
Internally, all virtual users, if their login succeeds, are then mapped to just one real user (the so-called FTP 'guest user'). This user should be put in a chroot jail after login and should have many other security restrictions as well (ie limited uploading/downloading of files).
 
Old 01-18-2006, 10:52 AM   #10
ajs318
LQ Newbie
 
Registered: Apr 2004
Location: East Midlands
Distribution: Debian SID; Mandrake
Posts: 17

Rep: Reputation: 0
Quote:
Originally Posted by timmeke
If you have it, using the "nologin" program is actually better than the "false" or "true" programs.
"nologin" is especially provided to disallow logins, so it's simply better suited for the job.
How so?

As I understand it, if /etc/nologin exists then /bin/login will display the contents of this file and exit, unless you try to login as root. This means only root can login. While this may be desirable for systems under maintenance {e.g. while the disc on which /home resides is being repaired} it isn't much good if you want to be able to allow some users to login to a shell, but not others.
Quote:
Originally Posted by timmeke
As for having FTP users without a real login, you should consider using "virtual users". Most modern FTP daemons, like vsftpd - and probably also proftpd - support this feature. Simply said, you create a database of ftp users that don't have real logins (no real users, so they're called virtual users) and you allow users access to FTP if they have a login in that database. Internally, all virtual users, if their login succeeds, are then mapped to just one real user (the so-called FTP 'guest user'). This user should be put in a chroot jail after login and should have many other security restrictions as well (ie limited uploading/downloading of files).
Accomplishing what, exactly?

The chances are that all users will want an e-mail account, which requires individual user accounts anyway; and most will want web hosting, thereby {unfortunately IMHO} implying FTP. Apache makes it easy to set up virtual hosts using directories, so the logical thing is just to use users' individual home directories as the ServerRoot for their website.
 
Old 01-19-2006, 03:11 AM   #11
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 59
Quote:
Originally Posted by ajs318
As I understand it, if /etc/nologin exists then /bin/login will display the contents of this file and exit, unless you try to login as root. This means only root can login. While this may be desirable for systems under maintenance {e.g. while the disc on which /home resides is being repaired} it isn't much good if you want to be able to allow some users to login to a shell, but not others.
[QUOTE]
A quote from "man nologin":
It is inteded as a replacement shell field for accounts that have been disabled.
Quote:
This means that it dissallows logins and is a replacement shell. You could use as an alternative to /bin/false. But you're right. It's just an alternative, not necessarily better.


Quote:
Originally Posted by ajs318
The chances are that all users will want an e-mail account, which requires individual user accounts anyway; and most will want web hosting, thereby {unfortunately IMHO} implying FTP. Apache makes it easy to set up virtual hosts using directories, so the logical thing is just to use users' individual home directories as the ServerRoot for their website.
I just mentioned the notion of "virtual users" for completeness. If you use it or not, depends on your system. In this case, it would be easier indeed to set up real users.
I just didn't consider the possibilities of web hosting/e-mail for the users. Maybe I misread the post or was too fast to jump to conclusions.
My bad...
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Useradd - Cannot locate /etc/default/useradd in Solaris Paean Solaris / OpenSolaris 4 12-09-2005 01:36 AM
useradd jerryluis Fedora 9 03-27-2005 07:37 PM
Using Useradd spud Linux - Newbie 6 03-10-2005 03:50 PM
useradd cyrush Linux - Distributions 3 01-21-2003 09:40 PM
useradd qdickens Linux - General 4 11-02-2001 02:41 PM


All times are GMT -5. The time now is 01:47 PM.

Main Menu
 
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
Open Source Consulting | Domain Registration