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