Project

General

Profile

AFS Server » History » Version 8

Joseph Foley, 2019-01-17 21:18
rekeying!

1 1 Joseph Foley
h1. AFS Server
2
3
4
{{toc}}
5
6 8 Joseph Foley
h2. Important reminders
7
8
* Rekeying is different in 1.6 and 18.  http://docs.openafs.org/QuickStartUnix/HDRWQ50.html
9
10 1 Joseph Foley
h2. Tasks
11
12
h2. Desired Hardware
13
14
* Drobo (automated raid system with iSCSI) http://www.drobo.com/products/business/b1200i/index.php#!prettyPhoto
15
16
h2. Instructions
17
18 5 Joseph Foley
* [[rndnet-documentation:AFS_Client_Installation]]
19 1 Joseph Foley
* [[How To Add Users]]
20
21
h3. Guides/links
22
23
* OpenAFS Official Documentation http://docs.openafs.org/
24
* OpenAFS Detailed Guide http://techpubs.spinlocksolutions.com/dklar/afs.html
25
* slapd documentation https://help.ubuntu.com/community/OpenLDAPServer
26
* Kerberos/LDAP on Ubuntu (outdated) http://bobcares.com/blog/?p=435
27
* OpenAFS on Ubuntu (outdated) http://bobcares.com/blog/?p=501
28
* IBM AFS 3.6 Documentation http://www-01.ibm.com/software/stormgmt/afs/manuals/Library/unix/en_US/HTML/index.htm
29
* Interrealm AFS http://www.cs.cmu.edu/~help/afs/cross_realm.html
30
* AFS on Linux Presentation http://www.dia.uniroma3.it/~afscon09/docs/wiesand.pdf
31
* mod_waklog (apache integration with AFS) [[mod_waklog]]
32
* Kerberos and DNS http://www.faqs.org/faqs/kerberos-faq/general/section-47.html
33
* Adding another fileserver https://lists.openafs.org/pipermail/openafs-info/2006-September/023495.html
34
* Kerberos and AFS tutorial (Secure endpoints) http://www.secure-endpoints.com/talks/Kerberos_Tutorial_BPW2007.pdf
35 3 Joseph Foley
* Object storage:
36
** http://workshop.openafs.org/afsbpw08/talks/thu_3/OpenAFS+ObjectStorage.pdf
37
** http://www.dia.uniroma3.it/~afscon09/docs/reuter.pdf
38 1 Joseph Foley
* Key security issues
39
** http://openafs.org/pages/security/OPENAFS-SA-2013-003.txt
40
** http://www.openafs.org/pages/security/install-rxkad-k5-1.6.txt
41
42
h3. Getting started
43
44
* Install Ubuntu 12.04LTS
45
* Install Kerberos KDC (directions at [[Kerberos]])
46
* Setup DNS autodiscovery
47
<pre>
48 5 Joseph Foley
rnd.ru.is.		IN	AFSDB	1 afsdb1.rnd.ru.is.
49 1 Joseph Foley
</pre>
50
51
* Ubuntu
52
** client configuration is in @/etc/openafs@
53
** server configuration is in @/etc/openafs/server@
54
* CentOS
55
** client configuration is in @/var/vice/etc@ (the traditional)
56
** server configuration is in @/usr/afs/etc@
57
58
59
h3. Client
60
61
*Important!  Do this first!*
62
63 2 Joseph Foley
see [[AFS_Client_Installation]]
64 1 Joseph Foley
65
h3. Server
66
67
# Packages
68
<pre>sudo apt-get install openafs-krb5 openafs-{fileserver,dbserver}</pre>
69
70
h3. Keys and accounts
71
72
# Add entries to @/etc/openafs/CellServDB@ and @/etc/openafs/server/CellServDB@
73
## Note that the AFS cell *MUST* be lowercase
74
<pre>
75 5 Joseph Foley
>rnd.ru.is			# Reykjavik University
76
130.208.209.37			#afsdb1.rnd.objid.net 
77
130.208.209.39			#afsdb2.rnd.objid.net 
78
130.208.209.40			#afsdb3.rnd.objid.net 
79 1 Joseph Foley
</pre>
80
# Edit your @/etc/krb5.conf@
81
<pre>       
82
[libdefaults]
83
dns_lookup_kdc = true
84
dns_lookup_realm = true
85
86
[realms]
87 5 Joseph Foley
RND.RU.IS = {
88
                kdc = kerberos.rnd.ru.is
89
                kdc = kerberos-1.rnd.ru.is
90
                kdc = kerberos-2.rnd.ru.is
91
                admin_server = kerberos.rnd.ru.is
92 1 Joseph Foley
</pre>
93
94 5 Joseph Foley
# Add principal “afs/rnd.ru.is” and import the key to /etc/openafs/afs.keytab.  This is also a good time to setup the normal keytab.  Replace HOSTNAME with the reverse resolvable hostname.  If this is on greenqloud, you will need to make both the external name and the internal and add it to the keytab.
95 1 Joseph Foley
## WARNING:  If you run the kadmin, it will increment the kerberos version number, which will not allow the new servers to talk to the old.  Instead, copy the afs.keytab using scp to all of the machines!
96
<pre>
97
kadmin.local
98 5 Joseph Foley
kadmin: addprinc -policy service -randkey -e des-cbc-crc:normal afs/rnd.ru.is
99
kadmin: ktadd -k /etc/openafs/afs.keytab -e des-cbc-crc:normal afs/rnd.ru.is
100 1 Joseph Foley
kadmin: ank -policy host -randkey host/HOSTNAME
101
kadmin: ktadd host/HOSTNAME
102
kadmin: ank -policy host -randkey host/HOSTNAME
103
kadmin: ktadd host/INTERNALHOSTNAME
104
</pre>
105
# Remember the KVNO (key version number)
106
<pre>klist -ke /etc/openafs/afs.keytab</pre>
107
# Import the secret key into the AFS system.  Replace KVNO with the version number
108 5 Joseph Foley
<pre>asetkey add KVNO /etc/openafs/afs.keytab afs/rnd.ru.is
109 1 Joseph Foley
</pre>
110 4 Joseph Foley
# Copy the keytab to use the improved security
111 7 Joseph Foley
<pre>cp /etc/openafs/afs.keytab /etc/openafs/server/rxkad.keytab</pre>
112 1 Joseph Foley
#Now test with bos (afs-fileserver must be running, possibly restarted)
113
<pre>sudo service openafs-fileserver restart
114
sudo bos listkeys afsdb1 -localauth
115
#key 3 has cksum 2586520638
116
#Keys last changed on Fri Mar 30 02:10:25 2012.
117
#All done.
118
</pre> 
119
# Setup kerberized root shell access.  Replace my principal with yours or add it to the list.
120
<pre>
121
sudo vi /root/.krb5login
122 5 Joseph Foley
foley@RND.RU.IS
123 1 Joseph Foley
</pre>
124
# Test
125
<pre>ksu</pre>
126
127
h3. Partitions for vice (AFS cell)
128
129
# Make the partitions in your filesystem (as an image)
130
<pre>cd /home
131
sudo dd if=/dev/zero of=vicepa.img bs=100M count=80   # (8 GB partition)
132
sudo mkfs.ext4 vicepa.img
133
sudo sh -c "echo '/home/vicepa.img /vicepa ext4 defaults,loop 0 2' >> /etc/fstab"
134
sudo tune2fs -c 0 -i 0 -m 0 vicepa.img
135
</pre>
136
# Now we mount it
137
<pre>sudo mkdir -p /vicepa
138
sudo mount /vicepa
139
</pre>
140
To add more disks, see [[AFS Server#Adding-More-disks|Adding More disks]]
141
142
143
h3. Firewall settings
144
145
# Need to poke holes in the firewall also (http://security.fnal.gov/cookbook/KerberosPorts.html)
146
## Login to the firewall  @bridge.objid.net@
147
## Open these ports in @/etc/shorewall/rules@
148
<pre>## AFS and kerberos 
149
## From http://security.fnal.gov/cookbook/KerberosPorts.html
150
ACCEPT all    net:130.208.209.37-130.208.209.40 tcp,udp 88 #krb
151
ACCEPT all    net:130.208.209.37-130.208.209.40 tcp 749
152
ACCEPT all    net:130.208.209.37-130.208.209.40 tcp,udp 464
153
ACCEPT all    net:130.208.209.37-130.208.209.40 udp 749,4444
154
ACCEPT all    net:130.208.209.37-130.208.209.40 udp 9878
155
ACCEPT all    net:130.208.209.37-130.208.209.40 udp 7000:7007
156
157
</pre>
158
159
h3. Make the new cell
160
161
# If you get issues with the case on the afs cell (all UPPERCASE is bad)
162
## sudo dpkg-reconfigure openafs-client
163
## sudo dpkg-reconfigure openafs-fileserver
164
# Make the Cell!
165
<pre>sudo afs-newcell</pre>
166
## Yes, we meet the requirements
167
##Principal: root/admin
168
## If you have problems with the ip address in the CellServDB, make sure it matches in @/etc/hosts@!
169
## If you see issues about network connections, you probably have an orphan process or something running on that port.
170
## if you have to clear out the user database, it is in @/etc/openafs/server/ThisUser@
171
172
h3. Testing out the cell and making the root volume
173
174
# Test out kinit and tokens
175
<pre>sudo su # (We want to switch to the root user)
176
177
kinit root/admin
178
179
Password for root/admin@SPINLOCK.HR: PASSWORD
180
181
aklog
182
</pre>
183
## if you get errors, it means that weak crypto is not enabled
184
# Check out your tokens with @kinit -5f@ and @tokens@
185
# Now create the root volume
186
<pre>afs-rootvol
187
...
188
4) The AFS client must be running pointed at the new cell.
189
Do you meet these conditions? (y/n) y
190
191
You will need to select a server (hostname) and AFS partition on which to
192
create the root volumes.
193
194 4 Joseph Foley
What AFS Server should volumes be placed on? boron.rnd.ru.is
195 1 Joseph Foley
What partition? [a] a
196
</pre>
197
# Everything should now be happy!
198
# Add the update server to distribute config files over encrypted channel
199
<pre>sudo bos create localhost upserveretc simple  "/usr/lib/openafs/upserver  -crypt /etc/openafs" -localauth </pre>
200
# Add the backup server (database servers need this process)
201
<pre>sudo bos create localhost buserver simple "/usr/lib/openafs/buserver" -localauth</pre>
202
h3. Standard partitions
203
204 4 Joseph Foley
# Now we create some of the "standard" partitions.  This is based upon the MIT configuration.  Note that these all start with very small quota! and are their own "class".  You will need to schedule backup partitions for them individually.  Note that you will need to go to the read-write of the root which is /afs/.rnd.ru.is
205 1 Joseph Foley
<pre>
206 4 Joseph Foley
cd /afs/.rnd.ru.is
207 1 Joseph Foley
vos create afsdb1 a activity
208
vos create afsdb1 a course
209
vos create afsdb1 a project
210
vos create afsdb1 a software
211
vos create afsdb1 a system
212
vos create afsdb1 a dept
213
vos create afsdb1 a org
214
vos create afsdb1 a reference
215
</pre>
216
# Now we mount them in the root area
217
<pre>
218
fs mkmount activity activity
219
fs mkmount course course
220
fs mkmount project project
221
fs mkmount software software
222
fs mkmount system system
223
fs mkmount dept dept
224
fs mkmount org org
225
fs mkmount reference reference
226
</pre>
227
# Finally, since this is a read-only volume, we have to "release" it
228
<pre>vos release root.cell</pre>
229 4 Joseph Foley
# And check to make sure the new directories show up in /afs/rnd.ru.is
230 1 Joseph Foley
h3. Administrative users
231
232
* Login to the kerberos server as root and create an afsadm user
233
<pre>kadmin.local
234
addprinc addprinc -policy user <user>/afsadm
235
quit</pre>
236
* If you need super-super user capability, you will need to run this command with root/admin
237
<pre>kinit root/admin
238
aklog
239
bos adduser afsdb1 <user>/afsadm
240
</pre>
241
* Now you are a super-super user and can make the afs server dance.  Sometimes it takes a few minutes for the protection database to update, so you might have to wait.  Unfortunately, you are not done, you still need to add them to the group system:administrators so they can do other useful operations.
242
* Create an equivalent user to the Kerberos user
243
<pre>pts createuser <user>.afsadm</pre>
244
* Add them to the group system:administrators.  You may need to wait for the ptserver to sync up
245
<pre>pts adduser <user>.afsadm system:administrators</pre>
246
247
248
h3. Backup partitions
249
250
* Create all backup partitions everywhere!
251
<pre> vos backupsys </pre>
252
* Automate backup of user partitions at 1:00 and the temp partition at 0:01
253
<pre>bos create afsdb1 backupusers cron -cmd "/usr/bin/vos backupsys -prefix user -localauth" "1:00"
254
bos create afsdb1 backuptemp cron -cmd "/usr/bin/vos backupsys -prefix temp -localauth" "0:01"
255
</pre>
256
* now go create Oldfiles in the appropriate places
257 4 Joseph Foley
<pre>cd /afs/rnd.ru.is/user/f/fo/foley
258 1 Joseph Foley
fs mkmount Oldfiles user.foley.backup
259
</pre>
260
261
h3. Adding More disks
262
263
http://docs.openafs.org/AdminGuide/ch03s08.html
264
265
# Get administrator tickets and tokens/var/lib/openafs/local
266
<pre> kinit <something>/afsadm; aklog
267
</pre>
268
# format and partition them with ext4 and give them a useful name for later.  For example
269
## figure out the next /vicep?? name, in this case it is /vicepb
270
<pre>fdisk /dev/sdb1
271
mkfs.ext4 -L grylavicepb /dev/sdb1</pre>
272
# Add the appropriate entry to /etc/fstab
273
<pre>echo "/dev/sdb1 /vicepb ext4 defaults 0 2" >> /etc/fstab</pre>
274
# See if it gets mounted properly
275
<pre>sudo mount -a </pre>
276
# Kick the fs service to get it to rescan and notice the disk
277
<pre>bos restart <machine name>  fs</pre>
278
# it should now show up  on the list of partitions
279
<pre>vos listpart afsdb1</pre>
280
# now you can make new volumes
281
282
h3. Multihomed servers
283
284
It can be a problem if one of the network interfaces is on a private network (like gryla).  You can restrict which network interfaces the server interfaces by putting NetInfo and NetRestrict files in @/var/lib/openafs/local@
285
286
More info at http://docs.openafs.org/AdminGuide/ch03s09.html
287
288
h3. Installing another server
289
290
These instructions were from examining the afs-newcell script by Sam Hartmans. Make sure you are logged in as root.
291
*Also, make sure that you do not have the hostname as 127.0.0.1 in /etc/hosts!*
292
# Stop the client
293
<pre>service openafs-client stop</pre>
294
# Stop the server
295
<pre>service openafs-fileserver stop</pre>
296
# Copy the afs.keytab from a running server
297 4 Joseph Foley
<pre>scp root@lithium.rnd.ru.is:/etc/openafs/server/afs.keytab /etc/openafs/server/afs.keytab</pre>
298 1 Joseph Foley
# Install the key
299 4 Joseph Foley
<pre>asetkey add 3 /etc/openafs/server/afs.keytab afs/rnd.ru.is</pre>
300
# Install the more secure key (see the security advisory)
301
<pre> cp afs.keytab rxkad.keytab
302 1 Joseph Foley
# Edit the CellServDB in @/etc/openafs/server/CellServDB@ and append it to the end of @/etc/openafs/CelServDB@ if it isn't already in there.
303
# Secure, but possibly database corrupting:
304
## STart up the server
305
<pre> service openafs-fileserver start </pre>
306
## Add the admin user through bos
307
<pre>bos adduser afscell1 root.admin -localauth</pre>
308
## Create initial protection database by hand.  Bit of a hack
309
<pre>pt_util -p /var/lib/openafs/db/prdb.DB0 -w</pre>
310
### start typing in these commands exactly.  Note the space before the last line!
311
<pre>root.admin 128/20 1 -204 -204
312
system:administrators 130/20 -204 -204 -204
313
 root.admin 1</pre>
314
## start up the ptserver and vlserver
315
<pre>bos create afscell1 ptserver simple /usr/lib/openafs/ptserver -localauth
316
bos create afscell1 vlserver simple /usr/lib/openafs/vlserver -localauth
317
</pre>
318
# Less secure, but more traditional
319
## Shutdown the server
320
<pre> service openafs-fileserver stop </pre>
321
## Startup in noauth mode
322
<pre>/usr/sbin/bosserver -noauth</pre>
323
## Add the admin user through bos
324
<pre>bos adduser localhost root.admin -noauth</pre>
325
## Protection database and vlserver
326
<pre>bos create localhost ptserver simple /usr/lib/openafs/ptserver -noauth
327
bos create localhost vlserver simple /usr/lib/openafs/vlserver -noauth
328
</pre>
329
## Make sure that systems:administrators has root.admin in it
330
<pre>pts membership system:administrators -noauth</pre>
331
## Kill the unauthenticated bosserver
332
<pre>pkill bosserver</pre>
333
## Start the bos server
334
<pre> service openafs-fileserver start </pre>
335
# start up the fileserver
336
<pre>bos create localhost fs fs -cmd /usr/lib/openafs/fileserver -cmd /usr/lib/openafs/volserver -cmd /usr/lib/openafs/salvager -localauth</pre>
337
# setup the backup server
338
<pre>sudo bos create localhost buserver simple "/usr/lib/openafs/buserver" -localauth</pre>
339
# setup the update clients to make /etc/openafs sync correctly every 2 hours
340 4 Joseph Foley
<pre>sudo bos create -server localhost -instance upclientetc -type simple -cmd "/usr/lib/openafs/upclient afsdb1.rnd.ru.is -crypt -t 120 /etc/openafs"</pre>
341 1 Joseph Foley
# Wait for a while (30 sec) for the ubik to sync up
342
# Start up the client
343
<pre>service openafs-client start</pre>
344
# Check to make sure the servers are still running
345
<pre>bos status localhost</pre>
346 6 Joseph Foley
# Add your users (root.admin and foley.afsadm) to /etc/openafs/server/UserList so they can administer the cell
347 1 Joseph Foley
# You are ready to make volumes in the partition and mount them!
348
349
h3. Replication
350
351 4 Joseph Foley
It is a good idea to replicate files that are changed infrequently, particularly the root.afs and other bottom level directories.  Remember that you will need to only change things in the read-write /afs/.rnd.ru.is then do a <pre>vos release <id></pre>.
352 5 Joseph Foley
foley has created a script example in @/afs/rnd.ru.is/project/rndnet/Scripts/afs-replicate-vols.sh@
353 1 Joseph Foley
354
# Create the replications on the various servers
355 5 Joseph Foley
<pre>vos addsite afsdb2.rnd.ru.is a root.afs
356
vos addsite samvinna.rnd.ru.is a root.afs
357 1 Joseph Foley
</pre>
358
# Now setup a bos job to release them on a regular schedule http://docs.openafs.org/AdminGuide/ch04s05.html
359
<pre>
360 5 Joseph Foley
bos create afsdb1.rnd.ru.is releaserootafs cron "/usr/bin/vos release root.afs -local" 0:00
361
bos create afsdb1.rnd.ru.is releaserootcell cron "/usr/bin/vos release root.cell -local" 0:00
362 1 Joseph Foley
</pre>
363
364
h2.  Shared keys and multiple Kerberos realms
365
366
h3.  Shared keys
367
368
Log into the servers and create matching krbtgt principals with matching KVNO.  (Make sure the kvno matches or it will not work.)
369
Copies of the magic passwords are on the servers at @/etc/krb5kdc/sharedpw.txt@
370
371 5 Joseph Foley
Commands for crossrealm between CS.RU.IS and RND.RU.IS
372 1 Joseph Foley
<pre>kadmin.local  -e "des3-hmac-sha1:normal des-cbc-crc:v4"
373 5 Joseph Foley
addprinc -requires_preauth krbtgt/RND.RU.IS@CS.RU.IS
374
addprinc -requires_preauth krbtgt/CS.RU.IS@RND.RU.IS
375 1 Joseph Foley
</pre>
376
377
You will then need to modify the @/etc/krb5.conf@ files on the clients.  (or setup DNS)
378
<pre>[capath]
379 5 Joseph Foley
RND.RU.IS = {
380 1 Joseph Foley
          CS.RU.IS = .
381
}
382
CS.RU.IS = {
383 5 Joseph Foley
         RND.RU.IS = .
384 1 Joseph Foley
}</pre>
385
386
To test it, get keys in one realm and see if you can kvno in the other
387
<pre>kinit foley@CS.RU.IS
388 5 Joseph Foley
kvno foley@RND.RU.IS</pre>
389 1 Joseph Foley
390
Once it is properly working, you can get service keys (such as AFS) in the other realm.
391
<pre>kinit foley@CS.RU.IS
392 5 Joseph Foley
aklog rnd.ru.is
393 1 Joseph Foley
 klist
394
Ticket cache: FILE:/tmp/krb5cc_7812_A14864
395
Default principal: foley@CS.RU.IS
396
397
Valid starting    Expires           Service principal
398
17/04/2013 02:09  18/04/2013 02:09  krbtgt/CS.RU.IS@CS.RU.IS
399 5 Joseph Foley
17/04/2013 02:09  18/04/2013 02:09  krbtgt/RND.RU.IS@CS.RU.IS
400
17/04/2013 02:09  18/04/2013 02:09  afs/rnd.ru.is@RND.RU.IS
401 1 Joseph Foley
</pre>
402
403
404
h3. Multiple realms
405
406
# put a space separated list of the valid kerberos realms to map into @/etc/openafs/server/krb.conf@ then restart.
407
** If you're feeling lazy, login to the DB servers and run:
408 5 Joseph Foley
<pre>cp /afs/rnd.ru.is/project/rndnet/SVN/Machines/AFSDB1/etc/openafs/server/krb.conf /etc/openafs/server/.
409 1 Joseph Foley
bos restart localhost -localauth -all
410
</pre>
411
# then add the afs service keys into the KeyList
412
413
414
h1. CentOs setup
415
416
* https://www.sit.auckland.ac.nz/Installing_OpenAFS_on_Red_Hat_distributions_including_Fedora
417
418
h2. AFS Client
419
420
# add this to /usr/vice/etc/CellServDB
421
<pre>>ru.is          #Reykjavik University
422 5 Joseph Foley
130.208.209.47  #njord.rnd.ru.is
423 1 Joseph Foley
</pre>
424
425
h2. AFS Server 
426
427
# sudo yum install -y openafs-server
428
# edit /usr/afs/etc/CellServDB
429
<pre>ru.is #Reykjavik University
430 5 Joseph Foley
njord.rnd.ru.is   130.208.209.47
431 1 Joseph Foley
</pre>
432
433
h1. Active Directory
434
435
Go here for the [[ActiveDirectory KDC]] setup
436
437
h1. Status
438
439
* Machines number 1, 3 and 5 on the stack above the catalyst (counted from the top) have ubuntu 10.04 installed and sshd running.
440
* root password: 100feet
441
* Number 2 and 4 are broken. 2 does not boot and 4 has errors in RAM and does not detect a disk.
442
* Network is set up and Ubuntu installed.
443 5 Joseph Foley
** gryla (130.208.209.37)  kerberos server, kadmin server, AFSDB server (rnd.ru.is), AFSCELL server (rnd.ru.is a and b)
444 1 Joseph Foley
** stekkjastaur (130.208.209.39)
445
** giljagaur (130.208.209.40).
446 5 Joseph Foley
* No proper DNS for now, so they are in Joe's rnd.objid.net domain (e.g., gryla.rnd.objid.net).
447 1 Joseph Foley
448
h1. Frequently Asked Questions
449
450
h2. I set it up, but the bos commands aren't working and the filserver isn't starting.  The FileLog says something about "Couldn't get CPS for AnyUser"
451
452
Chances are good that your keys aren't properly setup.  https://lists.openafs.org/pipermail/openafs-info/2001-December/002736.html
453
Make sure that the kvno is correct for all of the AFS keys installed on all of the servers.