Project

General

Profile

AFS Server » History » Version 6

Joseph Foley, 2016-05-26 13:52
UserList!

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