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