source: branches/fc17-dev/server/doc/ @ 2081

Last change on this file since 2081 was 2080, checked in by ezyang, 13 years ago
Information on how to reenable password SSH.
File size: 16.8 KB
1# This document is a how-to for installing a Fedora server.
2# It is semi-vaguely in the form of a shell script, but is not really
3# runnable as it stands.
5# Notation
6# [PRODUCTION] Production server that will be put into the pool
7# [WIZARD]     Semi-production server that will only have
8#              daemon.scripts-security-upd bits, among other
9#              restricted permissions
10# [TESTSERVER] Completely untrusted server
12# 'branch' is the current svn branch you are on.  You want to
13# use trunk if your just installing a new server, and branches/fcXX-dev
14# if your preparing a server on a new Fedora release.
17# 'server' is the public hostname of your server, for SCP'ing files
18# to and from.
21# ----------------------------->8--------------------------------------
22#                       FIRST TIME INSTRUCTIONS
24# [PRODUCTION] If this is the first time you've installed this hostname,
25# you will need to update a bunch of files to add support for it. These
26# include:
27#   o Adding all aliases to /etc/httpd/conf.d/scripts-vhost-names.conf
28#     (usually this is hostname,, h-n,,
29#     scriptsN,, and the IP address.)
30#   o Adding routing rules for the static IP in
31#     /etc/sysconfig/network-scripts/route-eth1
32#   o Adding the IP address to the hosts file (same hosts as for
33#     scripts-vhost-names)
34#   o Update SSH config at
35#       - server/fedora/config/etc/ssh/shosts.equiv
36#       - server/fedora/config/etc/ssh/ssh_known_hosts
37#       - server/fedora/config/etc/ssh/sshd_config : DenyUsers
38#     (the last part is critical to ensure that rooting one server
39#     doesn't give you root to all the other servers)
40#   o Put the hostname information in LDAP so SVN and Git work
41#   o Set up Nagios monitoring on sipb-noc for the host
42#   o Set up the host as in the pool on r-b/r-b /etc/heartbeat/
43#   o Update locker/etc/known_hosts
44#   o Update website files:
45#       /mit/scripts/web_scripts/home/server.css.cgi
46#       /mit/scripts/web_scripts/heartbeat/heartbeat.php
48# You will also need to prepare the keytabs for credit-card.  In particular,
49# use ktutil to combine the host/ and
50# host/ keys with host/ in
51# the keytab.  Do not use 'k5srvutil change' on the combined keytab
52# or you'll break the other servers. (real servers only).  Be
53# careful about writing out the keytab: if you write it to an
54# existing file the keys will just get appended.  The correct
55# credential list should look like:
56#   ktutil:  l
57#   slot KVNO Principal
58#   ---- ---- ---------------------------------------------------------------------
59#      1    5 host/
60#      2    3 host/
61#      3    2 host/
62#      4    8 host/
64# The LDAP keytab should be by itself, so be sure to delete it and
65# put it in its own file.
67# ----------------------------->8--------------------------------------
68#                      INFINITE INSTALLATION
70# Start with a Scripts kickstarted install of Fedora (install-fedora)
72# IMPORTANT: If you are installing a server without the benefit of
73# Kickstart (for example, you are installing on XVM, it is VITALLY
74# IMPORTANT that you go through the kickstart and apply all of the
75# necessary changes--for example, disabling selinux or enabling
76# network.)
77#   XXX We should make Kickstart work for test servers too
79# Take updates, reboot if there's a kernel update.
80    yum update -y
82# Get rid of network manager (XXX figure out to make kickstarter do
83# this for us)
84    yum remove NetworkManager
86# Make sure sendmail isn't installed
87    yum remove sendmail
89# Check out the scripts /etc configuration
90    cd /root
91    \cp -a etc /
92    chmod 0440 /etc/sudoers
94# [TEST] You'll need to fix some config now.  See bottom of document.
96# Make sure network is working.  Kickstart should have
97# configured eth0 and eth1 correctly; use service network restart
98# to add the new routes from etc in route-eth1.
99    systemctl restart network.service
100    # Check everything worked:
101    route
102    ifconfig
103    cat /etc/hosts
104    cat /etc/sysconfig/network-scripts/route-eth1
106# This is the point at which you should start updating scriptsified
107# packages for a new Fedora release.  Consult 'upgrade-tips' for more
108# information.
109    yum install -y scripts-base
110    # Some of these packages are naughty and clobber some of our files
111    cd /etc
112    svn revert resolv.conf hosts sysconfig/openafs nsswitch.conf
113    # Troubleshooting: if accountadm, tokensys and nscd fail to install
114    # you probably forgot to turn off selinux
116# Replace rsyslog with syslog-ng by doing:
117    rpm -e --nodeps rsyslog
118    yum install -y syslog-ng
119    systemctl enable syslog-ng.service
121# Install the full list of RPMs that users expect to be on the
122# servers.
123rpm -qa --queryformat "%{Name}.%{Arch}\n" | sort > packages.txt
124# arrange for packages.txt to be passed to the server, then run:
125# --skip-broken will (usually) prevent you from having to sit through
126# several minutes of dependency resolution until it decides that
127# it can't install /one/ package.
128    yum install -y --skip-broken $(cat packages.txt)
130# Check which packages are installed on your new server that are not
131# in the snapshot, and remove ones that aren't needed for some reason
132# on the new machine.  Otherwise, aside from bloat, you may end up
133# with undesirable things for security, like sendmail.
134    rpm -qa --queryformat "%{Name}.%{Arch}\n" | grep -v kernel | sort > newpackages.txt
135    diff -u packages.txt newpackages.txt | grep -v kernel | less
136    # here's a cute script that removes all extra packages
137    yum erase -y $(grep -Fxvf packages.txt newpackages.txt)
138    # 20101208 - Mysteriously we manage to get these extra packages
139    # from kickstart: mcelog mobile-broadband-provider-info
140    # ModemManager PackageKit
142# We need an upstream version of cgi which we've packaged ourselves, but
143# it doesn't work with the haskell-platform package which expects
144# explicit versions.  So temporarily rpm -e the package, and then
145# install it again after you install haskell-platform.  [Note: You
146# probably won't need this in Fedora 17 or something, when the Haskell
147# Platform gets updated.] [It's not obvious to me that this actually
148# works]
149    rpm -e ghc-cgi-devel ghc-cgi
150    yum install -y haskell-platform
151    yumdownloader ghc-cgi
152    yumdownloader ghc-cgi-devel
153    rpm -i ghc-cgi*1.8.2*.rpm
155# ----------------------------->8--------------------------------------
156#                      SPHEROID SHENANIGANS
158# Note: Since ultimately we'd like to move away from using per-language
159# package manager and all of these be RPMs, it is of questionable
160# importance how much /good/ automation for these is necessary.
162# Warning: For a new release, we're supposed to check if Fedora has
163# packaged up the RPM.  Unfortunately we don't really have good incants
164# for this.
166# Install the full list of perl modules that users expect to be on the
167# servers.
168    cd /root
169    export PERL_MM_USE_DEFAULT=1
170    cpan # this is interactive, enter the next two lines
171        o conf prerequisites_policy follow
172        o conf commit
173# on a reference server
174perldoc -u perllocal | grep head2 | cut -f 3 -d '<' | cut -f 1 -d '|' | sort -u | perl -ne 'chomp; print "notest install $_\n" if system("rpm -q --whatprovides \"perl($_)\" >/dev/null 2>/dev/null")' > perl-packages.txt
175# arrange for perl-packages.txt to be transferred to server
176    cat perl-packages.txt | perl -MCPAN -e shell
178# Install the Python eggs and Ruby gems and PEAR/PECL doohickeys that are on
179# the other servers and do not have RPMs.
180# The general mode of operation will be to run the "list" command
181# on both servers, see what the differences are, check if those diffs
182# are packaged up as rpms, and install them (rpm if possible, native otherwise)
183# - Look at /usr/lib/python2.6/site-packages and
184#           /usr/lib64/python2.6/site-packages for Python eggs and modules.
185#   There will be a lot of gunk that was installed from packages;
186#   easy-install.pth in /usr/lib/ will tell you what was easy_installed.
187#   First use 'yum search' to see if the relevant package is now available
188#   as an RPM, and install that if it is.  If not, then use easy_install.
189#   Pass -Z to easy_install to install them unzipped, as some zipped eggs
190#   want to be able to write to ~/.python-eggs.  (Also makes sourcediving
191#   easier.)
192# 'easy_install AuthKit jsonlib2 pygit'
193cat /usr/lib/python2.7/site-packages/easy-install.pth | grep "^./" | cut -c3- | cut -f1 -d- > egg.txt
194    cat egg.txt | xargs easy_install -Z
196# - Look at `gem list` for Ruby gems.
197#   Again, use 'yum search' and prefer RPMs, but failing that, 'gem install'.
198#       ezyang: rspec-rails depends on rspec, and will override the Yum
199#       package, so... don't use that RPM yet
200# XXX This doesn't do the right thing for old version gems
201gem list --no-version > gem.txt
202    gem install $(gem list --no-version | grep -Fxvf - gem.txt)
203    # Also, we need to install the old rails version
204    gem install -v=2.3.5 rails
206# - Look at `pear list` for Pear fruits (or whatever they're called).
207#   Yet again, 'yum search' for RPMs before resorting to 'pear install'.  Note
208#   that for things in the beta repo, you'll need 'pear install package-beta'.
209#   (you might get complaints about the php_scripts module; ignore them)
210pear list | tail -n +4 | cut -f 1 -d " " > pear.txt
211    pear config-set preferred_state beta
212    pear channel-update
213    pear install $(pear list | tail -n +4 | cut -f 1 -d " " | grep -Fxvf - pear.txt)
215# - Look at `pecl list` for PECL things.  'yum search', and if you must,
216#   'pecl install' needed items. If it doesn't work, try 'pear install
217#   pecl/foo' or 'pecl install foo-beta' or those two combined.
218pecl list | tail -n +4 | cut -f 1 -d " " > pecl.txt
219    pecl install --nodeps $(pecl list | tail -n +4 | cut -f 1 -d " " | grep -Fxvf - pecl.txt)
221# ----------------------------->8--------------------------------------
222#                       INFINITE CONFIGURATION
224# Create fedora-ds user (needed for credit-card)
225useradd -u 103 -r -d /var/lib/dirsrv fedora-ds
227# Run credit-card to clone in credentials and make things runabble
228python push $server
230# This is superseded by credit-card, but only for [PRODUCTION]
231# Don't use credit-card on [WIZARD]: it will put in the wrong creds!
233#   # All types of servers will have an /etc/daemon.keytab file, however,
234#   # different types of server will have different credentials in this
235#   # keytab.
236#   #   [PRODUCTION] daemon.scripts
237#   #   [WIZARD]     daemon.scripts-security-upd
238#   #   [TESTSERVER] daemon.scripts-test
240# [PRODUCTION/WIZARD] Fix the openafs /usr/vice/etc <-> /etc/openafs
241# mapping.
242    echo "/afs:/usr/vice/cache:10000000" > /usr/vice/etc/cacheinfo
243    echo "" > /usr/vice/etc/ThisCell
244# [TESTSERVER] If you're installing a test server, this needs to be
245# much smaller; the max filesize on XVM is 10GB.  Pick something like
246# 500000. Also, some of the AFS parameters are kind of retarded (and if
247# you're low on disk space, will actually exhaust our inodes).  Edit
248# these parameters in /etc/sysconfig/openafs (This doesn't work in the
249# new systemd world order: try editing the unit file instead.)
250    echo "/afs:/usr/vice/cache:500000" > /usr/vice/etc/cacheinfo
251    vim /etc/sysconfig/openafs
253# Test that zephyr is working
254    systemctl enable zhm.service
255    systemctl start zhm.service
256    echo 'Test!' | zwrite -d -c scripts -i test
258# Check out the scripts /usr/vice/etc configuration
259    cd /root/vice
260    \cp -a etc /usr/vice
262# [PRODUCTION] Set up replication (see ./install-ldap).
263# You'll need the LDAP keytab for this server: be sure to chown it
264# fedora-ds after you create the fedora-ds user
265    ls -l /etc/dirsrv/keytab
266    cat install-ldap
268# Enable lots of services
269    systemctl enable openafs-client.service
270    systemctl enable dirsrv.service
271    systemctl enable nslcd.service
272    systemctl enable nscd.service
273    systemctl enable postfix.service
274    systemctl enable nrpe.service
275    systemctl enable httpd.service # not for [WIZARD]
277    systemctl start openafs-client.service
278    systemctl start dirsrv.service
279    systemctl start nslcd.service
280    systemctl start nscd.service
281    systemctl start postfix.service
282    systemctl start nrpe.service
283    systemctl start httpd.service # not for [WIZARD]
285# Note about OpenAFS: Check that fs sysname is correct.  You should see,
286# among others, 'amd64_fedoraX_scripts' (vary X) and 'scripts'. If it's
287# not, you probably did a distro upgrade and should update
288# /etc/sysconfig/openafs (XXX this is wrong: figuring out new
289# systemd world order).
290    fs sysname
292# Postfix doesn't actually deliver mail; fix this
293    cd /etc/postfix
294    postmap virtual
296# Munin might not be monitoring packages that were installed after it
297    munin-node-configure --suggest --shell | sh
299# Run fmtutil-sys --all, which does something that makes TeX work.
300# (Note: this errors on XeTeX which is ok.)
301    fmtutil-sys --all
303# Ensure that PHP isn't broken:
304    mkdir /tmp/sessions
305    chmod 01777 /tmp/sessions
306    # XXX: this seems to get deleted if tmp gets cleaned up, so we
307    # might need something a little better (maybe init script.)
309# Fix etc by making sure none of our config files got overwritten
310    cd /etc
311    svn status -q
312    # Some usual candidates for clobbering include nsswitch.conf,
313    # resolv.conf and sysconfig/openafs
314    # [WIZARD/TEST] Remember that changes you made should not get
315    # reverted!
317# Reboot the machine to restore a consistent state, in case you
318# changed anything. (Note: Starting kdump fails (this is ok))
320# ------------------------------->8-------------------------------
323# [OPTIONAL] Your machine's hostname is baked in at install time;
324# in the rare case you need to change it: it appears to be in:
325#   o /etc/sysconfig/network
326#   o your lvm thingies; probably don't need to edit
328# [TESTSERVER] Enable password log in
329        vim /etc/ssh/sshd_config
330        service sshd reload
331        vim /etc/pam.d/sshd
332# Replace the first auth block with:
333#           # If they're not root, but their user exists (success),
334#           auth    [success=ignore ignore=ignore default=1] uid > 0
335#           # print the "You don't have tickets" error:
336#           auth    [success=die ignore=reset default=die] file=/etc/
337#           # If !(they are root),
338#           auth    [success=1 ignore=ignore default=ignore] uid eq 0
339#           # print the "your account doesn't exist" error:
340#           auth    [success=die ignore=reset default=die] file=/etc/
343# [WIZARD/TESTSERVER] If you are setting up a non-production server,
344# there are some services that it won't provide, and you will need to
345# make it talk to a real server instead.  In particular:
346#   - We don't serve the web, so don't bind
347#   - We don't serve LDAP, so use another server
348# This involves editing the following files:
349        \rm /etc/sysconfig/network-scripts/ifcfg-lo:{0,1,2,3}
350        \rm /etc/sysconfig/network-scripts/route-eth1 # [TESTSERVER] only
351#   o /etc/nslcd.conf
352#       replace: uri ldapi://%2fvar%2frun%2fdirsrv%2fslapd-scripts.socket/
353#       with: uri ldap://
354#           (what happened to nss-ldapd?)
355#   o /etc/openldap/ldap.conf
356#       add: URI ldap://
357#            BASE dc=scripts,dc=mit,dc=edu
358#   o /etc/httpd/conf.d/vhost_ldap.conf
359#       replace: VhostLDAPUrl "ldap://,dc=scripts,dc=mit,dc=edu"
360#       with: VhostLDAPUrl "ldap://,dc=scripts,dc=mit,dc=edu"
361#   o /etc/postfix/virtual-alias-{domains,maps}
362#       replace: server_host ldapi://%2fvar%2frun%2fdirsrv%2fslapd-scripts.socket/
363#       with: server_host = ldap://
364# to use instead of localhost.
365# XXX: someone should write sed scripts to do this
367# [WIZARD/TESTSERVER] If you are setting up a non-production server,
368# afsagent's cronjob will attempt to be renewing with the wrong
369# credentials (daemon.scripts). Change this:
370    vim /home/afsagent/renew # replace all mentions of
373#   - You need a self-signed SSL cert or Apache will refuse to start
374#     or do SSL.  Generate with:
375    openssl req -new -x509 -keyout /etc/pki/tls/private/scripts.key -out /etc/pki/tls/certs/scripts.cert -nodes
376#     Also make /etc/pki/tls/certs/ca.pem match up (XXX what's the
377#     incant for that?)
379# [TESTSERVER] More stuff for test servers
380#   - Make (/etc/aliases) root mail go to /dev/null, so we don't spam people
381#   - Edit /etc/httpd/conf.d/scripts-vhost-names.conf to have
382#     be an accepted vhost name
383#   - Look at the old test server and see what config changes are floating around
Note: See TracBrowser for help on using the repository browser.