xref: /openbsd/share/man/man8/afterboot.8 (revision 4bdff4be)
1.\"	$OpenBSD: afterboot.8,v 1.174 2023/03/15 21:42:23 benno Exp $
2.\"
3.\" Copyright (c) 1997 Marshall M. Midden
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\"
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\"    must display the following acknowledgement:
17.\"	This product includes software developed by Marshall M. Midden.
18.\" 4. The name of the author may not be used to endorse or promote products
19.\"    derived from this software without specific prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31.\"
32.Dd $Mdocdate: March 15 2023 $
33.Dt AFTERBOOT 8
34.\" Originally created by Marshall M. Midden -- 1997-10-20, m4@umn.edu
35.Os
36.Sh NAME
37.Nm afterboot
38.Nd things to check after the first complete boot
39.Sh DESCRIPTION
40.Ss Starting out
41This document attempts to list items for the system administrator
42to check and set up after the installation and first complete boot of the
43system.
44The idea is to create a list of items that can be checked off so that you have
45a warm fuzzy feeling that something obvious has not been missed.
46A basic knowledge of
47.Ux
48is assumed, otherwise type:
49.Pp
50.Dl $ help
51.Pp
52Complete instructions for correcting and fixing items are not provided.
53There are manual pages and other methodologies available for doing that.
54For example, to view the man page for the
55.Xr ls 1
56command, type:
57.Pp
58.Dl $ man 1 ls
59.Pp
60Administrators will rapidly become more familiar with
61.Ox
62if they get used to using the high quality manual pages.
63.Pp
64Some base programs and subsystems also come with sample configuration
65files in
66.Pa /etc/examples .
67.Ss Errata
68By the time that you have installed your system, it is possible that
69bugs in the release have been found.
70Security or reliability fixes can be found at
71.Lk https://www.openbsd.org/errata.html .
72Binary updates are made available for some architectures and can be installed
73using
74.Xr syspatch 8 .
75.Ss Login
76Log in on the console, or over the network using
77.Xr ssh 1 .
78For security reasons, it is bad practice to log in as root during regular use
79and maintenance of the system.
80Instead, administrators are encouraged to add a
81.Dq regular
82user, add said user to the
83.Dq wheel
84group, then use the
85.Xr su 1
86and
87.Xr doas 1
88commands when root privileges are required.
89.Pp
90The installation process provides an option to set up a user account.
91By default, accounts created via this method are automatically added to
92the
93.Dq wheel
94group.
95If that option was not used, see the paragraph
96.Sx Add new users
97below.
98.Pp
99To deny root logins over the network, edit the
100.Pa /etc/ssh/sshd_config
101file and set
102.Cm PermitRootLogin
103to
104.Dq no
105(see
106.Xr sshd_config 5 ) .
107.Ss Root password
108Change the password for the root user.
109(Note that throughout the documentation, the term
110.Dq superuser
111is a synonym for the root user.)
112Choose a password that has digits and special characters
113as well as from the upper and lower case alphabet.
114Do not choose any word in any language.
115It is common for an intruder to use dictionary attacks.
116Type the following command to change it:
117.Pp
118.Dl # passwd root
119.Pp
120To avoid the possibility of rogue files placed in
121the superuser's
122.Ev PATH ,
123it should never contain the current directory
124.Pq Dq \&. .
125.Ss System date
126.Xr ntpd 8
127is used to automatically synchronize clocks with remote NTP servers.
128You can use
129.Xr ntpctl 8
130to check the status.
131To change the NTP server, see
132.Xr ntpd.conf 5 .
133.Pp
134Check the system date with the
135.Xr date 1
136command.
137If needed, change the date, and/or change the symbolic link of
138.Pa /etc/localtime
139to the correct time zone in the
140.Pa /usr/share/zoneinfo
141directory.
142.Pp
143Examples:
144.Pp
145Set the current date to January 27th, 2016 3:04pm:
146.Dl # date 201601271504
147.Pp
148Set the time zone to Atlantic Standard Time:
149.Dl # ln -fs /usr/share/zoneinfo/Canada/Atlantic /etc/localtime
150.Ss Check hostname
151Use the
152.Ic hostname
153command to verify that the name of your machine is correct.
154See the man page for
155.Xr hostname 1
156if it needs to be changed.
157You will also need to edit the
158.Pa /etc/myname
159file to have it stick around for the next reboot.
160.Ss Verify network interface configuration and routing tables
161The first thing to do is an
162.Ic ifconfig -a
163to see if the network interfaces are properly configured.
164Correct by editing
165.Pa /etc/hostname. Ns Ar interface
166(where
167.Ar interface
168is the interface name or link layer address, e.g.,
169.Dq em0 )
170and then using
171.Xr ifconfig 8
172to manually configure it
173if you do not wish to reboot.
174Read the
175.Xr hostname.if 5
176man page for more information on the format of
177.Pa /etc/hostname. Ns Ar interface
178files and instructions on configuring dynamic addresses.
179.Pp
180Routing tables are manipulated using
181.Xr route 8 .
182They can be viewed by issuing
183.Dq route -n show .
184The default gateway address is stored in the
185.Xr mygate 5
186file.
187If you need to edit this file, a painless way to reconfigure the network
188afterwards is
189.Ic route flush
190followed by a
191.Ic sh -x /etc/netstart
192command.
193Or, you may prefer to manually configure using a series of
194.Ic route add
195and
196.Ic route delete
197commands.
198.Pp
199Packets are not forwarded by default, due to RFC requirements.
200If you wish to route packets between interfaces, add one or both
201of the following directives (depending on whether IPv4 or IPv6 routing
202is required) to
203.Xr sysctl.conf 5 :
204.Pp
205.Dl net.inet.ip.forwarding=1
206.Dl net.inet6.ip6.forwarding=1
207.Pp
208See
209.Xr multicast 4
210for instructions on configuring multicast routing.
211.Ss Check DNS
212Use
213.Xr host 1
214or
215.Xr dig 1
216to check that domain name resolution is working properly.
217.Pp
218Most likely, the IP address of at least one domain name server
219was added to
220.Xr resolv.conf 5
221while installing the system.
222.Xr resolvd 8
223maintains
224.Pa /etc/resolv.conf
225at runtime.
226.Pp
227A
228.Xr hosts 5
229file can be used if there is a need for system specific name
230resolution entries.
231.Ss Check disk mounts
232Check that the disks are mounted correctly by
233comparing the
234.Pa /etc/fstab
235file against the output of the
236.Xr mount 8
237and
238.Xr df 1
239commands.
240Example:
241.Bd -literal -offset indent
242# cat /etc/fstab
243/dev/sd0a / ffs rw 1 1
244/dev/sd0d /usr ffs rw,nodev 1 2
245/dev/sd0e /var ffs rw,nodev,nosuid 1 3
246/dev/sd0g /tmp ffs rw,nodev,nosuid 1 4
247/dev/sd0h /home ffs rw,nodev,nosuid 1 5
248
249# mount
250/dev/sd0a on / type ffs (local)
251/dev/sd0d on /usr type ffs (local, nodev)
252/dev/sd0e on /var type ffs (local, nodev, nosuid)
253/dev/sd0g on /tmp type ffs (local, nodev, nosuid)
254/dev/sd0h on /home type ffs (local, nodev, nosuid)
255
256# df
257Filesystem  1024-blocks     Used    Avail Capacity  Mounted on
258/dev/sd0a         22311    14589     6606    69%    /
259/dev/sd0d        203399   150221    43008    78%    /usr
260/dev/sd0e         10447      682     9242     7%    /var
261/dev/sd0g         18823        2    17879     0%    /tmp
262/dev/sd0h          7519     5255     1888    74%    /home
263
264# pstat -s
265Device      512-blocks     Used    Avail Capacity  Priority
266/dev/sd0b       131072    84656    46416    65%    0
267.Ed
268.Pp
269Edit
270.Pa /etc/fstab
271and use the
272.Xr mount 8
273and
274.Xr umount 8
275commands as appropriate.
276Refer to the above example and
277.Xr fstab 5
278for information on the format of this file.
279.Pp
280You may wish to do NFS partitions now too, or you can do them later.
281.Ss Check the running system
282You can use
283.Xr ps 1 ,
284.Xr netstat 1 ,
285and
286.Xr fstat 1
287to check on running processes, network connections, and opened files,
288respectively.
289.Sh FURTHER CHANGES
290The system should be usable now, but you may wish to do more customizing,
291such as adding users, etc.
292We suggest that you
293.Ic cd /etc
294and edit any files in that directory as necessary.
295.Pp
296Note that the
297.Pa /etc/motd
298file is modified by
299.Pa /etc/rc
300whenever the system is booted.
301To keep any custom message intact, ensure that you leave two blank lines
302at the top, or your message will be overwritten.
303.Ss Add new users
304Add users.
305There is an
306.Xr adduser 8
307script.
308You may use
309.Xr vipw 8
310to add users to the
311.Pa /etc/passwd
312file
313and edit
314.Pa /etc/group
315by hand to add new groups.
316You may also wish to edit
317.Pa /etc/login.conf
318and tune some of the limits documented in
319.Xr login.conf 5 .
320The manual page for
321.Xr su 1
322tells you to make sure to put people in
323the
324.Sq wheel
325group if they need root access.
326For example:
327.Pp
328.Dl wheel:*:0:root,myself
329.Ss System command scripts
330The
331.Pa /etc/rc.*\&
332scripts are invoked at boot time, after single-user mode has exited,
333and at shutdown.
334The whole process is controlled, more or less, by the master script
335.Pa /etc/rc .
336This script should not be changed by administrators.
337.Pp
338.Pa /etc/rc
339is in turn influenced by the configuration variables present in
340.Pa /etc/rc.conf .
341Again, this script should not be changed by administrators:
342site-specific changes should be made to
343.Pq freshly created if necessary
344.Pa /etc/rc.conf.local
345or by using the
346.Xr rcctl 8
347utility.
348.Pp
349Any commands which should be run before the system sets its
350secure level should be made to
351.Pa /etc/rc.securelevel ,
352and commands to be run after the system sets its
353secure level should be made to
354.Pa /etc/rc.local .
355Commands to be run before system shutdown should be set in
356.Pa /etc/rc.shutdown .
357.Pp
358For more information about system startup/shutdown files, see
359.Xr rc 8 ,
360.Xr rc.conf 8 ,
361.Xr securelevel 7 ,
362and
363.Xr rc.shutdown 8 .
364.Pp
365If you've installed X, you may want to turn on
366.Xr xenodm 1 ,
367the X Display Manager.
368To do this, change the value of
369.Va xenodm_flags
370in
371.Pa /etc/rc.conf.local .
372.Ss Set keyboard type
373Some architectures permit keyboard type control.
374Use the
375.Xr kbd 8
376command to change the keyboard encoding.
377.Ic kbd -l
378will list all available encodings.
379.Ic kbd xxx
380will select the
381.Ic xxx
382encoding.
383Store the encoding in
384.Pa /etc/kbdtype
385to make sure it is set automatically at boot time.
386.Ss Printers
387Edit
388.Pa /etc/printcap
389and
390.Pa /etc/hosts.lpd
391to get any printers set up.
392Consult
393.Xr lpd 8
394and
395.Xr printcap 5
396if needed.
397.Ss Audio and video recording
398The
399.Xr audio 4
400and
401.Xr video 4
402drivers by default record only silence and blanked images.
403Normal recording can be enabled by adding the following directives to
404.Xr sysctl.conf 5 :
405.Bd -literal -offset indent
406kern.audio.record=1
407kern.video.record=1
408.Ed
409.Ss Power management
410If the BIOS supports it,
411.Xr apmd 8
412can be configured to act on different events and adjust device performance.
413In the following example it is configured to start on boot in automatic
414performance adjustment mode and suspend the system if no AC is connected and
415the estimated battery life is equal or below 15%:
416.Bd -literal -offset indent
417# rcctl set apmd status on
418# rcctl set apmd flags -A -z 15
419.Ed
420.Ss Mail aliases
421Edit
422.Pa /etc/mail/aliases
423and set the three standard aliases to go to either a mailing list, or
424the system administrator.
425.Bd -literal -offset indent
426# Well-known aliases -- these should be filled in!
427root:		sysadm
428manager:	root
429dumper:		root
430.Ed
431.Ss Mail
432The default mail agent on
433.Ox
434is
435.Xr smtpd 8 .
436Details on how to configure an alternative mailer are documented in
437.Xr mailer.conf 5 .
438.Pp
439.Ox
440ships with a default
441.Pa /etc/mail/smtpd.conf
442file that will work for simple installations.
443See
444.Xr smtpd.conf 5
445for information on configuring more complex setups.
446For the default installation,
447.Xr smtpd 8
448is configured to only accept connections from the local host.
449This makes it possible to send mail locally, but not receive mail from remote
450servers, which is ideal if you have one central incoming mail machine and
451several clients.
452To cause smtpd to accept external network connections, modify the
453.Ic listen on
454directive in
455.Pa /etc/mail/smtpd.conf
456to include the interfaces to listen on.
457.Ss Daily, weekly, monthly scripts
458Review
459.Xr daily 8
460to understand what the periodic system maintenance scripts do and
461how to customize them:
462For example, to enable
463.Ev ROOTBACKUP
464or to add local maintenance code to
465.Pa /etc/daily.local , /etc/weekly.local ,
466or
467.Pa /etc/monthly.local .
468.Ss Tighten up security
469You might wish to tighten up security more by editing
470.Pa /etc/fbtab
471as when installing X.
472Look at the other files in
473.Pa /etc
474and edit them as needed.
475(Do not edit files ending in
476.Pa .db
477\(em like
478.Pa pwd.db , spwd.db ,
479nor
480.Pa localtime ,
481nor
482.Pa rmt ,
483nor any directories.)
484.Ss Crontab (background running processes)
485Check what is running by typing
486.Ic crontab -l
487as root
488and see if anything unexpected is present.
489Do you need anything else?
490Do you wish to change things?
491See
492.Xr crontab 5 .
493.Ss Next day cleanup
494After the first night's
495.Xr security 8
496run, change ownerships and permissions
497on files, directories, and devices; root may have received mail
498with subject: "<hostname> daily insecurity output".
499This mail contains a set of security recommendations,
500presented as a list looking something like this:
501.Bd -literal -offset indent
502var/mail:
503        permissions (0755, 0775)
504etc/daily:
505        user (0, 3)
506.Ed
507.Pp
508The best bet is to follow the advice in that list.
509The recommended setting is the first item in parentheses, while
510the current setting is the second one.
511This list is generated by
512.Xr mtree 8
513using
514.Pa /etc/mtree/special .
515Use
516.Xr chmod 1 ,
517.Xr chgrp 1 ,
518and
519.Xr chown 8
520as needed.
521.Ss Daemons
522Enable/disable any daemon processes as necessary.
523.Xr intro 8
524contains a comprehensive guide to the various daemons available on the
525.Ox
526system.
527.Ss Packages
528Install your own packages.
529The
530.Ox
531ports collection includes a large set of third-party software.
532Most of it is available as binary packages that you can install using
533.Xr pkg_add 1 .
534See
535.Xr packages 7
536for more details.
537To start daemons installed from packages, see
538.Xr rc.d 8 .
539.Pp
540There is also other third-party software that is available
541in source form only, either because it has not been ported to
542.Ox
543yet, or because licensing restrictions make binary redistribution
544impossible.
545Sometimes checking the mailing lists for
546past problems that people have encountered will result in a fix posted.
547.Ss Compiling a kernel
548Information on building and modifying kernels
549is contained within
550.Xr config 8 .
551.Sh SEE ALSO
552.Xr doas 1 ,
553.Xr ksh 1 ,
554.Xr man 1 ,
555.Xr pkg_add 1 ,
556.Xr ps 1 ,
557.Xr vi 1 ,
558.Xr multicast 4 ,
559.Xr hier 7 ,
560.Xr config 8 ,
561.Xr dmesg 8 ,
562.Xr ifconfig 8 ,
563.Xr intro 8 ,
564.Xr rcctl 8 ,
565.Xr sysctl 8
566.Sh HISTORY
567This document first appeared in
568.Ox 2.2 .
569