fix spacing
[mirror/dsa-wiki.git] / input / howto / new-machine.creole
1 == setup/integrate a new machine ==
2
3 Note: this is partially obsolete now that we have [[puppet-setup|puppet]].  We should probably update/rework some parts.
4
5 ** Warning: This procedure has not been tested since being moved to the wiki.  Beware. **
6
7 * install ssh if it isn't there already
8 {{{
9     apt-get install ssh
10 }}}
11
12 * make apt sane
13 {{{
14     echo 'Acquire::PDiffs "false";' > /etc/apt/apt.conf.d/local-pdiff
15     echo 'APT::Install-Recommends 0;' > /etc/apt/apt.conf.d/local-recommends
16 }}}
17
18 * sane locales:
19
20  make sure there is _no_ locale defined in /etc/environment and /etc/default/locale
21
22 * make debconf the same on every host: - dialog, - high
23 {{{
24     dpkg-reconfigure debconf
25 }}}
26
27 * add db.d.o to sources.list:
28 {{{
29     cat > /etc/apt/sources.list.d/debian.org.list << EOF
30 deb     http://db.debian.org/debian-admin lenny main
31 deb-src http://db.debian.org/debian-admin lenny main
32 EOF
33
34     apt-key add - << EOF
35 -----BEGIN PGP PUBLIC KEY BLOCK-----
36 Version: GnuPG v1.4.6 (GNU/Linux)
37
38 mQGiBEf4BP0RBACfXnRhBb9HKiA3h5A1tDnluVwfkSuDX4ZXdVAuMZapdOm8r9ug
39 9zE/dDGWPWja+DArAPZ/i3BFvlMewmden/IFbQKtXluQVIC4GL1RBMwrtWsZzo0g
40 picl3CYWDAYjRdg4WppUc9FawwGw081FlLGDv7eYRO3+8uGUHfr+SD7CwwCgxJK6
41 SvDX6M2Ifuq8WmgWWrVFyakD/ipdxd3NPIcnl1JTO2NjbOJYKpZMl6v0g+1OofSq
42 CAKTO8ymc0z6SF1j/4mWe1W76wvTpOhOUgn2WO7SQHZaujb/3z+yAJedfbCDgq0S
43 H/T2qbQTzv+woAjyR/e2Zpsc2DRfqO/8aCw1Jx8N3UbH9MBPYlYlyCnSra1OAyXW
44 VvC0A/9nT/k6VIFBF0Oq2WwmzOLptOqg61WrnxBr3GIe503++p88tOwlCJlL0uZZ
45 k68m3m5t7WDtQK4fHQwLramb9AqtBPhiEaXU5bXk77RYE54EeEH9Z4H4YSMMkdYU
46 gLG5CZI2jprxAZew1mHKROv+15jxYd+BZCrORmpWn5g7N+TC5rQeZGIuZGViaWFu
47 Lm9yZyBhcmNoaXZlIGtleSAyMDA4iGYEExECACYFAkf4BP0CGwMFCQHhM4AGCwkI
48 BwMCBBUCCAMEFgIDAQIeAQIXgAAKCRC+p88QvSsO4JZLAJ4slp2uRZHtzMXK8oTB
49 DV1XiztTZwCfQD7Y2mKDaMsmE4AmwOOTw2fmcZo=
50 =+jlJ
51 -----END PGP PUBLIC KEY BLOCK-----
52 EOF
53 }}}
54
55 * in /etc/ssh/sshd_config:
56 ** disable the DSA hostkey, so that it only does RSA
57 ** remove old host keys: <BR>{{{
58     cd /etc/ssh/ && rm ssh_host_dsa_key ssh_host_dsa_key.pub ssh_host_key ssh_host_key.pub
59 }}}
60 ** disable X11 forwarding
61 ** Tell it to use alternate authorized_keys locations
62 {{{
63     | HostKey /etc/ssh/ssh_host_rsa_key
64     | X11Forwarding no
65     | AuthorizedKeysFile /etc/ssh/userkeys/%u
66     | AuthorizedKeysFile2 /var/lib/misc/userkeys/%u
67
68     vi /etc/ssh/sshd_config
69     (cd / && env -i /etc/init.d/ssh restart)
70 }}}
71
72   * maybe link root's auth key there:
73 {{{
74     mkdir -p /etc/ssh/userkeys && ln -s /root/.ssh/authorized_keys /etc/ssh/userkeys/root
75 }}}
76
77
78 * install userdir-ldap
79 {{{
80     apt-get update && apt-get install userdir-ldap
81 }}}
82
83
84 * on samosa, add the host to /home/sshdist/.ssh/authorized_keys and generate.conf
85 (you want the host's rsa host key there: {{{cat /etc/ssh/ssh_host_rsa_key.pub}}})
86 {{{
87     : :: samosa :: && sudo vi /home/sshdist/.ssh/authorized_keys
88     : :: samosa :: && sudo vi /etc/userdir-ldap/generate.conf
89 }}}
90 * run generate, or wait until cron runs it for you
91 {{{
92     : :: samosa :: && sudo -u sshdist ud-generate
93 }}}
94
95 * fix nsswitch for ud fu.
96 {{{
97     sed -i -e 's/^passwd:\[[:space:]]\+compat$/passwd:         compat db/;
98               s/^group:\[[:space:]]\+compat$/group:          db compat/;
99               s/^shadow:\[[:space:]]\+compat$/shadow:         compat db/' \
100         /etc/nsswitch.conf
101 }}}
102
103 (you might have to restart sshd here:
104 {{{
105     (cd / && env -i /etc/init.d/ssh restart)
106 }}}
107 )
108
109 * on the host, run ud-replicate
110 {{{
111     mkdir -p /root/.ssh &&
112     echo db,db.debian.org,192.25.206.57 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAph3LozYmcwHwgnxfKia1lg1AXNuJiEroi/GpPztbcqxmFOYBZbMgYDj+kM+usoXF2diT9OQWqg1yx19CeEoghHYz4/yZa0PYdLgPj9Si4PScekVaE051GrLM63osfK0j3wIfpgLJv2/zs42NbXjkKPdjInEaWPn8W1fe88M3JDE= root@newsamosa >> /root/.ssh/known_hosts &&
113     ud-replicate
114 }}}
115
116 * check if it worked:
117 {{{
118     id weasel
119 }}}
120
121 * add pam_mkhomedir to common-session:
122 {{{
123     grep pam_mkhomedir /etc/pam.d/common-session || \
124     echo "session optional        pam_mkhomedir.so skel=/etc/skel umask=0022" >> /etc/pam.d/common-session
125 }}}
126
127 * install debian.org which brings you shells and much other fun
128 {{{
129     apt-get install debian.org
130 }}}
131
132 * try to login using your user and ssh key.  you should get a homedir.
133
134 * make ca-certificates sane:  (choose to *not* trust new certs, and we only want the spi cert activated)
135 {{{
136     sed -i -e 's/^[^#!].*/!&/; s#^!spi-inc.org/spi-cacert-2008.crt#spi-inc.org/spi-cacert-2008.crt#' /etc/ca-certificates.conf
137     dpkg-reconfigure ca-certificates
138 }}}
139
140 * exim setup:
141 {{{
142     : :: now obsolete :: &&
143     apt-get install git-core curl &&
144     ! [ -d /etc/exim4.bak ] &&
145     /etc/init.d/exim4 stop &&
146     mv /etc/exim4 /etc/exim4.bak &&
147     mkdir /etc/exim4 &&
148     cd /etc/exim4 &&
149     git clone https://db.debian.org/git/dsa-exim.git Git &&
150     ./Git/bin/update &&
151     (cd / && /etc/init.d/exim4 start)
152 }}}
153 * Add debian-admin@debian.org to root in /etc/aliases
154
155 * sane default editor
156 {{{
157     apt-get install vim && update-alternatives --set editor /usr/bin/vim.basic
158 }}}
159
160 * setup sudo
161 {{{
162     grep '^%adm' /etc/sudoers || echo '%adm    ALL=(ALL) ALL' >> /etc/sudoers
163     grep '^%adm.*apt-get' /etc/sudoers || echo '%adm    ALL=(ALL) NOPASSWD: /usr/bin/apt-get update, /usr/bin/apt-get dist-upgrade, /usr/bin/apt-get clean, /usr/sbin/samhain -t check -i -p err -s none -l none -m none' >> /etc/sudoers
164
165     apt-get install libpam-pwdfile
166     cat > /etc/pam.d/sudo << EOF
167 #%PAM-1.0
168
169 auth [authinfo_unavail=ignore success=done ignore=ignore default=die] pam_pwdfile.so pwdfile=/var/lib/misc/thishost/sudo-passwd
170 auth required pam_unix.so nullok_secure try_first_pass
171 #@include common-auth
172 @include common-account
173
174 session required pam_permit.so
175 session required pam_limits.so
176 EOF
177 }}}
178
179 * OPEN A NEW SHELL - DO _NOT_ LOG OUT OF THIS ONE:<BR>
180   test that the dedicated sudo password works.  if not, undo the pam sudo config.
181   (comment out the auth lines and include common-auth again)
182
183 * setup ldap.conf:
184 {{{
185     grep '^URI.*db.debian.org' /etc/ldap/ldap.conf || cat >> /etc/ldap/ldap.conf << EOF
186
187 URI             ldap://db.debian.org
188 BASE            dc=debian,dc=org
189
190 TLS_CACERT      /etc/ssl/certs/spi-cacert-2008.pem
191 TLS_REQCERT     hard
192 EOF
193 }}}
194
195 * munin setup:
196 * grant access to spohr
197 {{{
198     sed -i -e '/^allow/d; $ a \allow ^192\\\.25\\\.206\\\.57$\nallow ^192\\\.25\\\.206\\\.33$' /etc/munin/munin-node.conf
199     ( cd / && env -i /etc/init.d/munin-node restart )
200 }}}
201 * add to munin on spohr
202 {{{
203     : :: spohr :: && sudo vi /etc/munin/munin.conf
204 }}}
205
206
207 * add host to nagios config
208
209 * disable password auth with ssh, once you verified you can log in
210   and become root using keys.
211 {{{
212     vi /etc/ssh/sshd_config
213       | PasswordAuthentication no
214     (cd / && env -i /etc/init.d/ssh restart)
215 }}}
216
217 * if it is a HP Proliant, or has other management fu, read setup-oob
218
219 -- weasel, Wed, 04 Jun 2008 20:52:56 +0200