OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / util-linux / original / man1 / login.1
1 .\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
2 .\" May be distributed under the GNU General Public License
3 .TH LOGIN 1 "4 November 1996" "Util-linux 1.6" "Linux Programmer's Manual"
4 .SH NAME
5 login \- sign on
6 .SH SYNOPSIS
7 .BR "login [ " name " ]"
8 .br
9 .B "login \-p"
10 .br
11 .BR "login \-h " hostname
12 .br
13 .BR "login \-f " name
14 .SH DESCRIPTION
15 .B login
16 is used when signing onto a system.  It can also be used to switch from one
17 user to another at any time (most modern shells have support for this
18 feature built into them, however).
19
20 If an argument is not given,
21 .B login
22 prompts for the username.
23
24 If the user is
25 .I not
26 root, and if
27 .I /etc/nologin
28 exists, the contents of this file are printed to the screen, and the
29 login is terminated.  This is typically used to prevent logins when the
30 system is being taken down.
31
32 If special access restrictions are specified for the user in
33 .IR /etc/usertty ,
34 these must be met, or the log in attempt will be denied and a 
35 .B syslog
36 message will be generated. See the section on "Special Access Restrictions".
37
38 If the user is root, then the login must be occurring on a tty listed in
39 .IR /etc/securetty .
40 Failures will be logged with the
41 .B syslog
42 facility.
43
44 After these conditions have been checked, the password will be requested and
45 checked (if a password is required for this username).  Ten attempts
46 are allowed before
47 .B login
48 dies, but after the first three, the response starts to get very slow.
49 Login failures are reported via the
50 .B syslog
51 facility.  This facility is also used to report any successful root logins.
52
53 If the file
54 .I .hushlogin
55 exists, then a "quiet" login is performed (this disables the checking
56 of mail and the printing of the last login time and message of the day).
57 Otherwise, if
58 .I /var/log/lastlog
59 exists, the last login time is printed (and the current login is
60 recorded).
61
62 Random administrative things, such as setting the UID and GID of the
63 tty are performed.  The TERM environment variable is preserved, if it
64 exists (other environment variables are preserved if the
65 .B \-p
66 option is used).  Then the HOME, PATH, SHELL, TERM, MAIL, and LOGNAME
67 environment variables are set.  PATH defaults to
68 .I /usr/local/bin:/bin:/usr/bin
69 for normal users, and to
70 .I /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
71 for root.  Last, if this is not a "quiet" login, the message of the
72 day is printed and the file with the user's name in
73 .I /usr/spool/mail
74 will be checked, and a message printed if it has non-zero length.
75
76 The user's shell is then started.  If no shell is specified for the
77 user in
78 .BR /etc/passwd ,
79 then
80 .B /bin/sh
81 is used.  If there is no directory specified in
82 .IR /etc/passwd ,
83 then
84 .I /
85 is used (the home directory is checked for the
86 .I .hushlogin
87 file described above).
88 .SH OPTIONS
89 .TP
90 .B \-p
91 Used by
92 .BR getty (8)
93 to tell
94 .B login
95 not to destroy the environment
96 .TP
97 .B \-f
98 Used to skip a second login authentication.  This specifically does
99 .B not
100 work for root, and does not appear to work well under Linux.
101 .TP
102 .B \-h
103 Used by other servers (i.e.,
104 .BR telnetd (8))
105 to pass the name of the remote host to
106 .B login
107 so that it may be placed in utmp and wtmp.  Only the superuser may use
108 this option.
109
110 .SH "SPECIAL ACCESS RESTRICTIONS"
111 The file
112 .I /etc/securetty
113 lists the names of the ttys where root is allowed to log in. One name
114 of a tty device without the /dev/ prefix must be specified on each
115 line.  If the file does not exist, root is allowed to log in on any
116 tty.
117 .PP
118 On most modern Linux systems PAM (Pluggable Authentication Modules)
119 is used. On systems that do not use PAM, the file
120 .I /etc/usertty
121 specifies additional access restrictions for specific users.
122 If this file does not exist, no additional access restrictions are
123 imposed. The file consists of a sequence of sections. There are three
124 possible section types: CLASSES, GROUPS and USERS. A CLASSES section
125 defines classes of ttys and hostname patterns, A GROUPS section
126 defines allowed ttys and hosts on a per group basis, and a USERS
127 section defines allowed ttys and hosts on a per user basis.
128 .PP
129 Each line in this file in may be no longer than 255
130 characters. Comments start with # character and extend to the end of
131 the line.
132 .PP
133 .SS "The CLASSES Section"
134 A CLASSES section begins with the word CLASSES at the start of a line
135 in all upper case. Each following line until the start of a new
136 section or the end of the file consists of a sequence of words
137 separated by tabs or spaces. Each line defines a class of ttys and
138 host patterns.
139 .PP
140 The word at the beginning of a line becomes defined as a collective
141 name for the ttys and host patterns specified at the rest of the
142 line. This collective name can be used in any subsequent GROUPS or
143 USERS section. No such class name must occur as part of the definition
144 of a class in order to avoid problems with recursive classes.
145 .PP
146 An example CLASSES section:
147 .PP
148 .nf
149 .in +.5
150 CLASSES
151 myclass1                tty1 tty2
152 myclass2                tty3 @.foo.com
153 .in -.5
154 .fi
155 .PP
156 This defines the classes 
157 .I myclass1
158 and
159 .I myclass2
160 as the corresponding right hand sides.
161 .PP
162
163 .SS "The GROUPS Section"
164 A GROUPS section defines allowed ttys and hosts on a per Unix group basis. If
165 a user is a member of a Unix group according to 
166 .I /etc/passwd
167 and
168 .I /etc/group
169 and such a group is mentioned in a GROUPS section in 
170 .I /etc/usertty
171 then the user is granted access if the group is.
172 .PP
173 A GROUPS section starts with the word GROUPS in all upper case at the start of
174 a line, and each following line is a sequence of words separated by spaces
175 or tabs. The first word on a line is the name of the group and the rest
176 of the words on the line specifies the ttys and hosts where members of that
177 group are allowed access. These specifications may involve the use of
178 classes defined in previous CLASSES sections.
179 .PP
180 An example GROUPS section.
181 .PP
182 .nf
183 .in +0.5
184 GROUPS
185 sys             tty1 @.bar.edu
186 stud            myclass1 tty4
187 .in -0.5
188 .fi
189 .PP
190 This example specifies that members of group 
191 .I sys
192 may log in on tty1 and from hosts in the bar.edu domain. Users in
193 group
194 .I stud
195 may log in from hosts/ttys specified in the class myclass1 or from
196 tty4.
197 .PP
198
199 .SS "The USERS Section"
200 A USERS section starts with the word USERS in all upper case at the
201 start of a line, and each following line is a sequence of words
202 separated by spaces or tabs. The first word on a line is a username
203 and that user is allowed to log in on the ttys and from the hosts
204 mentioned on the rest of the line. These specifications may involve
205 classes defined in previous CLASSES sections.  If no section header is
206 specified at the top of the file, the first section defaults to be a
207 USERS section.
208 .PP
209 An example USERS section:
210 .PP
211 .nf
212 .in +0.5
213 USERS
214 zacho           tty1 @130.225.16.0/255.255.255.0
215 blue            tty3 myclass2
216 .in -0.5
217 .fi
218 .PP
219 This lets the user zacho login only on tty1 and from hosts with IP
220 addreses in the range 130.225.16.0 \- 130.225.16.255, and user blue is
221 allowed to log in from tty3 and whatever is specified in the class
222 myclass2.
223 .PP
224 There may be a line in a USERS section starting with a username of
225 *. This is a default rule and it will be applied to any user not
226 matching any other line.
227 .PP
228 If both a USERS line and GROUPS line match a user then the user is
229 allowed access from the union of all the ttys/hosts mentioned in these
230 specifications.
231
232 .SS Origins
233 The tty and host pattern specifications used in the specification of
234 classes, group and user access are called origins. An origin string
235 may have one of these formats:
236 .IP o 
237 The name of a tty device without the /dev/ prefix, for example tty1 or
238 ttyS0.
239 .PP
240 .IP o
241 The string @localhost, meaning that the user is allowed to
242 telnet/rlogin from the local host to the same host. This also allows
243 the user to for example run the command: xterm -e /bin/login.
244 .PP
245 .IP o
246 A domain name suffix such as @.some.dom, meaning that the user may
247 rlogin/telnet from any host whose domain name has the suffix
248 \&.some.dom.
249 .PP
250 .IP o
251 A range of IPv4 addresses, written @x.x.x.x/y.y.y.y where x.x.x.x is
252 the IP address in the usual dotted quad decimal notation, and y.y.y.y
253 is a bitmask in the same notation specifying which bits in the address
254 to compare with the IP address of the remote host. For example
255 @130.225.16.0/255.255.254.0 means that the user may rlogin/telnet from
256 any host whose IP address is in the range 130.225.16.0 \-
257 130.225.17.255.
258 .PP
259 Any of the above origins may be prefixed by a time specification
260 according to the syntax:
261 .PP
262 .nf
263 timespec    ::= '[' <day-or-hour> [':' <day-or-hour>]* ']'
264 day         ::= 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat' | 'sun'
265 hour        ::= '0' | '1' | ... | '23'
266 hourspec    ::= <hour> | <hour> '\-' <hour>
267 day-or-hour ::= <day> | <hourspec>
268 .fi
269 .PP
270 For example, the origin [mon:tue:wed:thu:fri:8\-17]tty3 means that log
271 in is allowed on mondays through fridays between 8:00 and 17:59 (5:59
272 pm) on tty3.  This also shows that an hour range a\-b includes all
273 moments between a:00 and b:59. A single hour specification (such as
274 10) means the time span between 10:00 and 10:59.
275 .PP
276 Not specifying any time prefix for a tty or host means log in from
277 that origin is allowed any time. If you give a time prefix be sure to
278 specify both a set of days and one or more hours or hour ranges. A
279 time specification may not include any white space.
280 .PP
281 If no default rule is given then users not matching any line
282 .I /etc/usertty
283 are allowed to log in from anywhere as is standard behavior.
284 .PP
285 .SH FILES
286 .nf
287 .I /var/run/utmp
288 .I /var/log/wtmp
289 .I /var/log/lastlog
290 .I /usr/spool/mail/*
291 .I /etc/motd
292 .I /etc/passwd
293 .I /etc/nologin
294 .I /etc/usertty
295 .I .hushlogin
296 .fi
297 .SH "SEE ALSO"
298 .BR init (8),
299 .BR getty (8),
300 .BR mail (1),
301 .BR passwd (1),
302 .BR passwd (5),
303 .BR environ (7),
304 .BR shutdown (8)
305 .SH BUGS
306
307 The undocumented BSD
308 .B \-r
309 option is not supported.  This may be required by some
310 .BR rlogind (8)
311 programs.
312
313 A recursive login, as used to be possible in the good old days,
314 no longer works; for most purposes
315 .BR su (1)
316 is a satisfactory substitute. Indeed, for security reasons,
317 login does a vhangup() system call to remove any possible
318 listening processes on the tty. This is to avoid password
319 sniffing. If one uses the command "login", then the surrounding shell
320 gets killed by vhangup() because it's no longer the true owner of the tty.
321 This can be avoided by using "exec login" in a top-level shell or xterm.
322 .SH AUTHOR
323 Derived from BSD login 5.40 (5/9/89) by Michael Glad (glad@daimi.dk)
324 for HP-UX
325 .br
326 Ported to Linux 0.12: Peter Orbaek (poe@daimi.aau.dk)