Kerberos Server » History » Version 1
Joseph Foley, 2015-09-05 02:52
| 1 | 1 | Joseph Foley | h1. Kerberos Server |
|---|---|---|---|
| 2 | |||
| 3 | [[Kerberos Tests]] |
||
| 4 | |||
| 5 | h2. Server Installation |
||
| 6 | |||
| 7 | h3. Guides |
||
| 8 | |||
| 9 | * MIT Kerberos KDC guide http://web.mit.edu/kerberos/krb5-current/doc/krb_admins/install_kdc.html |
||
| 10 | * Kerberos/LDAP on Ubuntu http://bobcares.com/blog/?p=435 |
||
| 11 | * Spinlock Guide on Kerberos http://techpubs.spinlocksolutions.com/dklar/kerberos.html |
||
| 12 | * http://www.rjsystems.nl/en/2100-kerberos-openldap-openafs-client.php |
||
| 13 | * Ubuntu Single Sign On https://help.ubuntu.com/community/SingleSignOn |
||
| 14 | * Ubuntu Kerberos https://help.ubuntu.com/community/Kerberos |
||
| 15 | * VISolve's guide http://www.visolve.com/system_services/opensource/security/ssh.php |
||
| 16 | * Stanford Guide to Kerberos on Debian http://itservices.stanford.edu/service/kerberos/install_debian |
||
| 17 | * Illinois NCSA Guide to Using Kerberos http://www.ncsa.illinois.edu/UserInfo/Resources/Software/kerberos/unix_clients.html |
||
| 18 | |||
| 19 | h3. DNS autodiscovery |
||
| 20 | |||
| 21 | http://www.rjsystems.nl/en/2100-dns-discovery-kerberos.php |
||
| 22 | |||
| 23 | <pre> |
||
| 24 | _kerberos._udp.DEV.RU.IS. IN SRV 10 0 88 gryla.dev.ru.is. |
||
| 25 | _kerberos._udp.DEV.RU.IS. IN SRV 20 0 88 stekkjarstaur.dev.ru.is. |
||
| 26 | _kerberos-master._udp.DEV.RU.IS. IN SRV 0 0 88 gryla.dev.ru.is. |
||
| 27 | _kerberos-adm._tcp.DEV.RU.IS. IN SRV 0 0 749 stekkjarstaur.dev.ru.is. |
||
| 28 | _kpasswd._udp.DEV.RU.IS. IN SRV 0 0 464 gryla.dev.ru.is. |
||
| 29 | </pre> |
||
| 30 | |||
| 31 | Don't forget to set autodiscovery up for [[AFS_Server]] also! |
||
| 32 | |||
| 33 | h3. Getting started |
||
| 34 | |||
| 35 | # Install the packages and setup the cache |
||
| 36 | <pre> |
||
| 37 | apt-get install krb5-kdc krb5-admin-server |
||
| 38 | </pre> |
||
| 39 | ** Our realm is @DEV.RU.IS@ |
||
| 40 | ** Kerberos server: @kerberos.dev.ru.is@ |
||
| 41 | ** Kerberos authoritative server: @kerberos.dev.ru.is@ |
||
| 42 | ** If you need to fix this later, run @dpkg-reconfigure krb5-config@ |
||
| 43 | # Setup the realm, including keys |
||
| 44 | <pre>krb5_newrealm</pre> |
||
| 45 | ** Temp master password: DrWhoNemesis |
||
| 46 | # Edit the @/etc/krb5.conf@ |
||
| 47 | ## search for @[domain_realm]@ and add these lines after |
||
| 48 | <pre> |
||
| 49 | .dev.ru.is = DEV.RU.IS |
||
| 50 | dev.ru.is = DEV.RU.IS |
||
| 51 | |||
| 52 | [logging] |
||
| 53 | kdc = FILE:/var/log/kerberos/krb5kdc.log |
||
| 54 | admin_server = FILE:/var/log/kerberos/kadmin.log |
||
| 55 | default = FILE:/var/log/kerberos/krb5lib.log |
||
| 56 | </pre> |
||
| 57 | ## Near the top under [libdefaults] |
||
| 58 | <pre> |
||
| 59 | dns_lookup_realm = true |
||
| 60 | dns_lookup_kdc = true |
||
| 61 | # need this for AFS |
||
| 62 | allow_weak_crypto = true |
||
| 63 | </pre> |
||
| 64 | # Make the empty log files |
||
| 65 | <pre> |
||
| 66 | sudo mkdir /var/log/kerberos |
||
| 67 | sudo touch /var/log/kerberos/{krb5kdc,kadmin,krb5lib}.log |
||
| 68 | sudo chmod -R 750 /var/log/kerberos |
||
| 69 | </pre> |
||
| 70 | |||
| 71 | h3. Time |
||
| 72 | |||
| 73 | # Kerberos only works if the clocks on clients and servers differ no more than a few minutes. SEtup an NTP server, preferably local. |
||
| 74 | <pre>sudo apt-get install ntp ntpdate</pre> |
||
| 75 | |||
| 76 | |||
| 77 | h3. Administrative user and KDC config |
||
| 78 | |||
| 79 | # Create an administrative user through @kadmin.local@ |
||
| 80 | <pre>kadmin.local |
||
| 81 | addprinc -policy admin administrator |
||
| 82 | addprinc -policy admin root/admin |
||
| 83 | </pre> |
||
| 84 | ** Our temp admin password is: MadameMing! |
||
| 85 | <pre>quit</pre> |
||
| 86 | # Edit @/etc/krb5kdc/kadm5.acl@ and add |
||
| 87 | <pre>*/admin * |
||
| 88 | administrator * |
||
| 89 | * il |
||
| 90 | */root admc host/* |
||
| 91 | </pre> |
||
| 92 | # Then restart the servers |
||
| 93 | <pre>service krb5-admin-server restart |
||
| 94 | service krb5-kdc restart |
||
| 95 | </pre> |
||
| 96 | # Set some requirements for principals |
||
| 97 | <pre>sudo kadmin.local |
||
| 98 | Authenticating as principal root/admin@SPINLOCK.HR with password. |
||
| 99 | |||
| 100 | kadmin.local: add_policy -minlength 8 -minclasses 3 admin |
||
| 101 | kadmin.local: add_policy -minlength 16 -minclasses 4 host |
||
| 102 | kadmin.local: add_policy -minlength 8 -minclasses 4 service |
||
| 103 | kadmin.local: add_policy -minlength 8 -minclasses 2 user |
||
| 104 | |||
| 105 | kadmin.local: quit |
||
| 106 | </pre> |
||
| 107 | h2. Configuration |
||
| 108 | |||
| 109 | # @/etc/krb5kdcs/krb5prop.sh@ is run every hour on @kerberos.dev.ru.is@ which propogates the full database to @kerberos-1@ and @kerberos-2@ |
||
| 110 | # crontab entry for root |
||
| 111 | <pre>23 * * * * /etc/krb5kdc/krb5prop.sh # sync from master</pre> |
||
| 112 | h3. Server Keys |
||
| 113 | |||
| 114 | * Make a principal and a keytab |
||
| 115 | <pre> |
||
| 116 | sudo kadmin -p root/admin |
||
| 117 | [sudo] password for foley: |
||
| 118 | Authenticating as principal root/admin with password. |
||
| 119 | Password for root/admin@DEV.RU.IS: |
||
| 120 | kadmin: addprinc -policy service -randkey host/gryla.dev.ru.is |
||
| 121 | Principal "host/gryla.dev.ru.is@DEV.RU.IS" created. |
||
| 122 | kadmin: ktadd -k /etc/krb5.keytab -norandkey host/gryla.dev.ru.is |
||
| 123 | kadmin: Principal -norandkey does not exist. |
||
| 124 | Entry for principal host/gryla.dev.ru.is with kvno 2, encryption type AES-256 CTS mode with 96-bit SHA-1 HMAC added to keytab WRFILE:/etc/krb5.keytab. |
||
| 125 | Entry for principal host/gryla.dev.ru.is with kvno 2, encryption type ArcFour with HMAC/md5 added to keytab WRFILE:/etc/krb5.keytab. |
||
| 126 | Entry for principal host/gryla.dev.ru.is with kvno 2, encryption type Triple DES cbc mode with HMAC/sha1 added to keytab WRFILE:/etc/krb5.keytab. |
||
| 127 | Entry for principal host/gryla.dev.ru.is with kvno 2, encryption type DES cbc mode with CRC-32 added to keytab WRFILE:/etc/krb5.keytab. |
||
| 128 | </pre> |
||
| 129 | |||
| 130 | h2. Kerberos slave server |
||
| 131 | |||
| 132 | * http://tldp.org/HOWTO/Kerberos-Infrastructure-HOWTO/server-replication.html |
||
| 133 | * http://www.rjsystems.nl/en/2100-kerberos-slave.php |
||
| 134 | |||
| 135 | h3. Install for kerberos master |
||
| 136 | |||
| 137 | # Setup the dump location |
||
| 138 | <pre>mkdir -p /var/lib/krb5dc/ |
||
| 139 | /var/lib/krb5dc/from_master</pre> |
||
| 140 | # Now setup the dump and sync scripts into @/etc/krb5kdc/krb5prop.sh@ |
||
| 141 | <pre> |
||
| 142 | #!/bin/bash |
||
| 143 | /usr/sbin/kdb5_util dump /var/lib/krb5kdc/slave_datatrans |
||
| 144 | /usr/sbin/kprop kerberos-1.dev.ru.is |
||
| 145 | /usr/sbin/kprop kerberos-2.dev.ru.is |
||
| 146 | |||
| 147 | chmod o+x krb5prop.sh@ |
||
| 148 | Now setup the crontab |
||
| 149 | sudo crontab -e@ |
||
| 150 | 30 * * * * /etc/krb5kdc/krb5prop.sh # sync from master</pre> |
||
| 151 | |||
| 152 | |||
| 153 | h3. Install for slave |
||
| 154 | |||
| 155 | This example is for stekkjarstaur.dev.ru.is. Change the hostname as neccessary. |
||
| 156 | |||
| 157 | # Install the servers and xinetd |
||
| 158 | ## sudo apt-get install krb5-kdc xinetd |
||
| 159 | # Get kerberos principals setup |
||
| 160 | <pre>addprinc -randkey host/stekkjarstaur.dev.ru.is |
||
| 161 | ktadd host/stekkjarstaur.dev.ru.is |
||
| 162 | Entry for principal host/stekkjarstaur.dev.ru.is with kvno 2, encryption type AES-256 CTS mode with 96-bit SHA-1 HMAC added to keytab WRFILE:/etc/krb5.keytab. |
||
| 163 | Entry for principal host/stekkjarstaur.dev.ru.is with kvno 2, encryption type ArcFour with HMAC/md5 added to keytab WRFILE:/etc/krb5.keytab. |
||
| 164 | Entry for principal host/stekkjarstaur.dev.ru.is with kvno 2, encryption type Triple DES cbc mode with HMAC/sha1 added to keytab WRFILE:/etc/krb5.keytab. |
||
| 165 | Entry for principal host/stekkjarstaur.dev.ru.is with kvno 2, encryption type DES cbc mode with CRC-32 added to keytab WRFILE:/etc/krb5.keytab. |
||
| 166 | </pre> |
||
| 167 | # Login to the slaves and make sure that kpropd is setup in xinetd |
||
| 168 | <pre>sudo emacs /etc/xinetd.d/krb_prop</pre> |
||
| 169 | ## Put this inside the file |
||
| 170 | <pre># default: on |
||
| 171 | service krb_prop |
||
| 172 | { |
||
| 173 | disable = no |
||
| 174 | socket_type = stream |
||
| 175 | id = krb_prop |
||
| 176 | protocol = tcp |
||
| 177 | user = root |
||
| 178 | wait = no |
||
| 179 | server = /usr/sbin/kpropd |
||
| 180 | }</pre> |
||
| 181 | ## Restart xinetd |
||
| 182 | <pre>sudo service xinetd restart</pre> |
||
| 183 | ## Note that this will not show up as an open port in nmap, I do not know why. |
||
| 184 | # Initialize an empty kerberos database |
||
| 185 | <pre>kdb5_util create |
||
| 186 | Loading random data |
||
| 187 | Initializing database '/etc/krb5kdc/principal' for realm 'DEV.RU.IS', |
||
| 188 | master key name 'K/M@DEV.RU.IS' |
||
| 189 | You will be prompted for the database Master Password. |
||
| 190 | It is important that you NOT FORGET this password. |
||
| 191 | Enter KDC database master key: |
||
| 192 | Re-enter KDC database master key to verify: |
||
| 193 | </pre> |
||
| 194 | ## Make sure this password is the same as the main master password to avoid a possible problem |
||
| 195 | # Setup the ACL file |
||
| 196 | <pre>vi /etc/krb5kdc/kpropd.acl</pre> |
||
| 197 | ## Add the principals of the master server |
||
| 198 | <pre>host/gryla.dev.ru.is@DEV.RU.IS</pre> |
||
| 199 | |||
| 200 | |||
| 201 | |||
| 202 | h1. Kerberized Clients |
||
| 203 | |||
| 204 | h2. Install |
||
| 205 | |||
| 206 | # Install the packages |
||
| 207 | <pre>sudo apt-get install krb5-clients</pre> |
||
| 208 | # Install openbsd's inetd server and config |
||
| 209 | <pre>sudo apt-get install openbsd-inetd |
||
| 210 | sudo apt-get install krb5-rsh-server |
||
| 211 | |||
| 212 | sudo update-rc.d -f openbsd-inetd remove |
||
| 213 | sudo update-rc.d openbsd-inetd defaults |
||
| 214 | |||
| 215 | sudo update-inetd --enable kshell |
||
| 216 | sudo update-inetd --enable eklogin |
||
| 217 | |||
| 218 | sudo invoke-rc.d openbsd-inetd restart |
||
| 219 | </pre> |
||
| 220 | # Setup the keytab on the host |
||
| 221 | <pre>sudo kadmin |
||
| 222 | [sudo] password for foley: |
||
| 223 | Authenticating as principal foley/admin@DEV.RU.IS with password. |
||
| 224 | Password for foley/admin@DEV.RU.IS: |
||
| 225 | kadmin: addprinc -policy service -randkey host/stekkjarstaur.dev.ru.is |
||
| 226 | Principal "host/stekkjarstaur.dev.ru.is@DEV.RU.IS" created. |
||
| 227 | kadmin: ktadd -k /etc/krb5.keytab -norandkey host/gryla.dev.ru.is |
||
| 228 | kadmin: Principal -norandkey does not exist. |
||
| 229 | Entry for principal host/gryla.dev.ru.is with kvno 2, encryption type AES-256 CTS mode with 96-bit SHA-1 HMAC added to keytab WRFILE:/etc/krb5.keytab. |
||
| 230 | Entry for principal host/gryla.dev.ru.is with kvno 2, encryption type ArcFour with HMAC/md5 added to keytab WRFILE:/etc/krb5.keytab. |
||
| 231 | Entry for principal host/gryla.dev.ru.is with kvno 2, encryption type Triple DES cbc mode with HMAC/sha1 added to keytab WRFILE:/etc/krb5.keytab. |
||
| 232 | Entry for principal host/gryla.dev.ru.is with kvno 2, encryption type DES cbc mode with CRC-32 added to keytab WRFILE:/etc/krb5.keytab. |
||
| 233 | |||
| 234 | </pre> |
||
| 235 | # Test with encryption and the ProtocolNew |
||
| 236 | <pre>krb5-rsh -x -PN gryla.dev.ru.is /bin/bash</pre> |
||
| 237 | ## You should now be able to run commands on the host! |
||
| 238 | |||
| 239 | h2. Changing Max Ticket Lifetime |
||
| 240 | |||
| 241 | From http://serverfault.com/questions/132123/how-to-change-the-kerberos-default-ticket-lifetime |
||
| 242 | |||
| 243 | Do this on each of the kerberos servers: kerberos, kerberos-1, kerberos-2 |
||
| 244 | |||
| 245 | # Become root |
||
| 246 | <pre> ksu </pre> |
||
| 247 | # edit /etc/krb5kdc/kdc.conf |
||
| 248 | # Change these values to ones you want. |
||
| 249 | <pre> max_life = 168h 0m 0s |
||
| 250 | max_renewable_life = 30d 0h 0m 0s |
||
| 251 | </pre> |
||
| 252 | # Restart the kdc |
||
| 253 | <pre>service krb5-kdc restart</pre> |
||
| 254 | # Fire up kadmin |
||
| 255 | <pre>kadmin</pre> |
||
| 256 | ## Change the max lifetime of the main tgt |
||
| 257 | <pre>modprinc -maxlife 168hours krbtgt/DEV.RU.IS</pre> |
||
| 258 | ## Change the max lifetime of the principal you want to be longer |
||
| 259 | <pre>modprinc -maxlife 168hours host/syslab.hir.is</pre> |
||
| 260 | # Test the modification |
||
| 261 | ## As a host |
||
| 262 | <pre>kinit -k -l 168h</pre> |
||
| 263 | ## or for a normal principal |
||
| 264 | <pre>kinit -l 168h foley</pre> |
||
| 265 | |||
| 266 | h3. AFS token lifetime |
||
| 267 | |||
| 268 | This is controlled partially by the afs entry in kerberos database. From http://docs.openafs.org/AdminGuide/ch02s10.html |
||
| 269 | |||
| 270 | # Fire up kadmin |
||
| 271 | <pre>kadmin</pre> |
||
| 272 | # Set the lifetimes on the AFS principal |
||
| 273 | <pre>modprinc -maxlife 168hours afs/dev.ru.is |
||
| 274 | |||
| 275 | |||
| 276 | h2. Issues |
||
| 277 | |||
| 278 | * You may get an connection refused. It usually means that the port is not correct. Add this line to the server's /etc/inetd.conf |
||
| 279 | <pre> klogin stream tcp nowait root /usr/sbin/tcpd /usr/sbin/klogin\ |
||
| 280 | d -5ec |
||
| 281 | </pre> |
||
| 282 | |||
| 283 | * If kerberos has issues, check on the PTR records and other DNS config. It is one of the things that gets checked by kerberos |
||
| 284 | ** Look into /etc/hosts and make sure that it matches the hostname in the ke |
||
| 285 | |||
| 286 | |||
| 287 | h1. LDAP install |
||
| 288 | |||
| 289 | # Install packages |
||
| 290 | <pre>apt-get install slapd ldap-utils libsasl2-modules-gssapi-mit</pre> |
||
| 291 | # Configure the administrator password for slapd (https://help.ubuntu.com/community/OpenLDAPServer) |
||
| 292 | <pre>slappasswd</pre> |
||
| 293 | ## Set password to: waynegretzky |
||
| 294 | ## Take the output: {SSHA}7UP8FDS0CZ8H8Hj8XPEtYkoeg0Cgy9bh |
||
| 295 | |||
| 296 | # Create organizational units in initial file @tree.ldif |
||
| 297 | <pre>dn: ou=users,dc=dev,dc=ru,dc=is |
||
| 298 | objectClass: organizationalUnit |
||
| 299 | ou:users |
||
| 300 | |||
| 301 | dn: ou=groups,dc=dev,dc=ru,dc=is |
||
| 302 | objectClass: organizationalUnit |
||
| 303 | ou: groups |
||
| 304 | </pre> |
||
| 305 | # Then add it to the ldap database |
||
| 306 | <pre>ldapadd -x -D "cn=admin,dc=dev,dc=ru,dc=is" -W -f tree.ldif</pre> |
||
| 307 | # These directions are unfinished due to inconsistencies in the config files and Ubuntu 10.04. LDAP is not critical to AFS, so installation and instructions will be delayed for now --foley |