Vous êtes sur la page 1sur 8

I.

Installation et configuration de KDC Kerberos

I.1. Installation

Nous utilisons la commande apt-cache search kerberos pour lister les


paquets disponibles.

debian:~#apt-cache search kerberos

krb5-admin-server - MIT Kerberos master server (kadmind)


krb5-clients - Secure replacements for ftp, telnet and rsh using MIT Kerberos
krb5-config - Configuration files for Kerberos Version 5
krb5-doc - Documentation for MIT Kerberos
krb5-ftpd - Secure FTP server supporting MIT Kerberos
krb5-kdc - MIT Kerberos key server (KDC)
krb5-rsh-server - Secure replacements for rshd and rlogind using MIT
Kerberos
krb5-telnetd - Secure telnet server supporting MIT Kerberos
krb5-user - Basic programs to authenticate using MIT Kerberos

Nous installons tous les paquets nécessaires :


debian:~#apt-get install krb5-kdc krb5-admin-server krb5-user

I.2. Configuration de base de Kerberos

Nous modifions les fichiers de configuration : /etc/kdb5.conf

[libdefaults]
default_realm = B2.R2SI.COM

B2.R2SI.COM = {
kdc = 192.168.100.1
admin_server = 192.168.100.1
default_domain = 192.168.100.1
}

Nous modifions aussi le fichier /etc/krb5kdc/kdc.conf :

B2.R2SI.COM = {
database_name = /var/lib/krb5kdc/principal
admin_keytab = FILE:/etc/krb5kdc/kadm5.keytab
....

Page 1 sur 8
Romain REBOTIER CS 530 – TP2 Novembre 2008
Jean-Marc DUFOUR P2009

Nous tapons ensuite la commande kdb5_util create -r B2.R2SI.COM –s


pour créer le royaume kerberos :

debian:/etc/krb5kdc# kdb5_util create -r B2.R2SI.COM -s


Loading random data
Initializing database '/var/lib/krb5kdc/principal' for realm 'B2.R2SI.COM',
master key name 'K/M@B2.R2SI.COM'
You will be prompted for the database Master Password.
It is important that you NOT FORGET this password.
Enter KDC database master key:
Re-enter KDC database master key to verify:

I.3. Définition de politiques

On utilise la commande kadmin.local pour configurer notre royaume


kerberos :

debian:~# kadmin.local
Authenticating as principal root/admin@B2.R2SI.COM with password.

La commande list_requests permet d’avoir la liste des commandes


disponibles. Pour définir les politiques demandées, on se rend compte qu’il
faut utiliser la commande add_policy :

kadmin.local: add_policy -maxlife "60 days" -minlength "12" admin


kadmin.local: add_policy -maxlife "45 days" -minlength "6" users

Rajout de admin
On rajoute l’utilisateur admin dans le groupe admin :

kadmin.local: addprinc -policy admin admin/admin@B2.R2SI.COM


Enter password for principal "admin/admin@B2.R2SI.COM":
Re-enter password for principal "admin/admin@B2.R2SI.COM":
add_principal: Password is too short while creating
"admin/admin@B2.R2SI.COM".

On remarque que le mot de passe renter est trop court… admin doit
respecter la politique de « admin », et donc le mot de passé doit avoir plus
de 12 caractères.

Rajout de admin et b
On rajoute les administrateurs admin et b :
kadmin.local: addprinc -policy admin admin/admin@B2.R2SI.COM
Enter password for principal "admin/admin@B2.R2SI.COM":

Page 2 sur 8
Romain REBOTIER CS 530 – TP2 Novembre 2008
Jean-Marc DUFOUR P2009

Re-enter password for principal "admin/admin@B2.R2SI.COM":


Principal "admin/admin@B2.R2SI.COM" created.
kadmin.local: addprinc -policy admin b/admin@B2.R2SI.COM
Enter password for principal "b/admin@B2.R2SI.COM":
Re-enter password for principal "b/admin@B2.R2SI.COM":
Principal "b/admin@B2.R2SI.COM" created.

On vérifie que les administrateurs ont bien été rajoutés :


kadmin.local: listprincs
K/M@B2.R2SI.COM
b/admin@B2.R2SI.COM
kadmin/admin@B2.R2SI.COM
kadmin/changepw@B2.R2SI.COM
kadmin/debian@B2.R2SI.COM
kadmin/history@B2.R2SI.COM
krbtgt/B2.R2SI.COM@B2.R2SI.COM
admin/admin@B2.R2SI.COM

Rajout de Martha, John et Lex


On rajoute les utilisateurs Martha, John et Lex :
kadmin.local: addprinc -policy users martha@B2.R2SI.COM
Enter password for principal "martha@B2.R2SI.COM":
Re-enter password for principal "martha@B2.R2SI.COM":
Principal "martha@B2.R2SI.COM" created.
kadmin.local: addprinc -policy users john@B2.R2SI.COM
Enter password for principal "john@B2.R2SI.COM":
Re-enter password for principal "john@B2.R2SI.COM":
Principal "john@B2.R2SI.COM" created.
kadmin.local: addprinc -policy users lex@B2.R2SI.COM
Enter password for principal "lex@B2.R2SI.COM":
Re-enter password for principal "lex@B2.R2SI.COM":
Principal "lex@B2.R2SI.COM" created.

Configuration des ACL


On crée le fichier /etc/krb5kdc/kadm5.acl dans lequel on définit les ACL :
admin/admin@B2.R2SI.COM *
b/admin@B2.R2SI.COM c
Admin a tous les droits (*) et b a uniquement le droit de changer les mots
de passe.

Connexion à distance
On configure kerberos sur la machine distante. Dans le fichier :
/etc/kdb5.conf on rajoute :
B2.R2SI.COM = {
kdc = 192.168.100.1
admin_server = 192.168.100.1
}

Page 3 sur 8
Romain REBOTIER CS 530 – TP2 Novembre 2008
Jean-Marc DUFOUR P2009

On utilise la commande kinit pour se connecter à notre serveur et générer


un tecket :
debian:/etc# kinit lex@B2.R2SI.COM
Password for lex@B2.R2SI.COM:

On utilise la commande klist à distance:


debian:/etc# klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: lex@B2.R2SI.COM

Valid starting Expires Service principal


12/08/08 04:19:29 12/08/08 14:19:29 krbtgt/B2.R2SI.COM@B2.R2SI.COM
renew until 12/09/08 04:19:14

Kerberos 4 ticket cache: /tmp/tkt0


klist: You have no tickets cached

On va voir dans /tmp le jeton Kerberos :


debian:/etc# ls /tmp/
coucou kde-root krb5cc_0 ksocket-root ssh-jlYlzP2932

Une fois la session terminée le jeton Kerberos est toujours dans /tmp. Pour
des questions de sécurité, nous préconisons donc de le détruire avec
kdestroy :

debian:/etc# kdestroy
debian:/etc# klist
klist: No credentials cache found (ticket cache FILE:/tmp/krb5cc_0)

Kerberos 4 ticket cache: /tmp/tkt0


klist: You have no tickets cached

II. Configuration des services « kerberized »

I. Red Hat et Fedora vous permettent d'activer et de désactiver


Kerberos démons de service réseau par l'intermédiaire des fichiers de
configuration dans le répertoire / etc / xinetd.d. Les fichiers suivants
doivent être présents:

1) klogin
2) eklogin
3) krb5-telnet
4) gssftp
5) kshell

Tous ces services peuvent être protégés par les TCP wrappers. Cela
peut être fait en éditant le fichier / etc / hosts.allow et / ou / etc /

Page 4 sur 8
Romain REBOTIER CS 530 – TP2 Novembre 2008
Jean-Marc DUFOUR P2009

hosts.deny fichiers de configuration. Votre configuration iptables


peut également être utilisée pour restreindre l'accès aux services.

 Les étapes :

Étape 1: Ajouter un principal hôte nouveau à la base de données


Kerberos

De la CLI kadmin (qui peut être invoquée sur n'importe quel client DAS
ou sur DAS-M), ajoutez le principal nouvel hôte pour le serveur
d'application à la base de données Kerberos. Il est probablement plus
facile d'exécuter cette commande à partir du serveur d'application,
puisque vous aurez besoin d'ajouter la clé de l'hôte de la keytab sur le
serveur d'application de toute façon. Le nom principal de l'hôte doit
contenir le nom de domaine complet du serveur

kadmin: addprinc -randkey host/post.b2.r2si.com


NOTICE: no policy specified for host/post.b2.r2si.com@B2.R2SI.COM;
assigning "default"
Principal " host/post.b2.r2si.com@B2.R2SI.COM" created.

Étape 2: générer le fichier keytab :

kadmin: ktadd host/post.b2.r2si.com

Étape 3 : Configuration de /etc/hosts.allow de TCP Wrappers

#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#

# Secure the Portmapper to our LAN


portmap : 127. 192.168.100. : ALLOW
portmap : ALL : DENY

### Kerberized services ###

Page 5 sur 8
Romain REBOTIER CS 530 – TP2 Novembre 2008
Jean-Marc DUFOUR P2009

## limit KLOGIN and EKLOGIN connections to local LAN and loopback


klogind : 127. 192.168.100. : ALLOW
klogind : ALL : DENY

## limit TELNET connections to local LAN and loopback


telnetd : 127. 10192.168.100. : ALLOW
telnetd : ALL : DENY

## limit Kerberized FTP connections to local LAN and loopback


ftpd : 127. 192.168.100. : ALLOW
ftpd : ALL : DENY

## limit RSH/RCP connections to local LAN and loopback


kshd : 192.168.100. : ALLOW
kshd : ALL : DENY

Étape 4: Activer les services en éditant les fichiers de configuration dans /


etc / xinetd.d.

Dans les fichiers:


 /etc/xinetd .d/gssftp
 /etc/xinetd.d/krb5 .telnet
 /etc/xinetd.d/eklogin:

On modifier la ligne enable =yes par enable =no pour activer les services.

Étape 5: Restart xinetd

[root@post xinetd.d]# /etc/init.d/xinetd restart


Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]

On utilise netsat pour afficher les services activé :

[root@post xinetd.d]# netstat -ta | grep LISTEN


tcp 0 0 *:kshell *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 *:ftp *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 *:telnet *:* LISTEN
tcp 0 0 *:eklogin *:* LISTEN
tcp 0 0 *:klogin *:* LISTEN

On ajoute les machines qui contiennent les services dans base kerberos comme
des principales.
Étape 1 et 2 telle que le nom host représente le nom de service kerberisé

Et on déplace le fichier krb5.keytab dans les machine client de réseau kerberisé


par la commande scp, et on modifié les droit d’utilisation de ce fichier.

Page 6 sur 8
Romain REBOTIER CS 530 – TP2 Novembre 2008
Jean-Marc DUFOUR P2009

 Exemples d'utilisation des services Kerberos

Le service Kerberos TELNET est similaire au service Kerberos RLOGIN. Il ne


crypter les informations d'authentification par défaut, le reste de la session est
envoyé "en clair". Vous devez utiliser l'option-a à utiliser TELNET dans ce mode.
Si vous ne spécifiez pas l'option-a (qui tente la connexion automatique), la
session va échouer.

Pour crypter toute la session, vous devez utiliser l'option-x. Ci-dessous, vous
verrez des exemples de tous les trois scénarios:

[kitty@ushas kitty]$ telnet post


Trying 192.168.100.1...
Connected to post.b2.r2si.com (192.168.100.4).
Escape character is '^]'.
telnetd: No authentication provided.
Connection closed by foreign host.

[kitty@ushas kitty]$ telnet -a post


Trying 192.168.100.1...
Connected to post.b2.r2si.com (192.168.100.4).
Escape character is '^]'.
[ Kerberos V5 accepts you as ``kitty@B2.R2SI.COM'' ]
Last login: Tue Jun 15 09:28:47 from ushas

######################
# #
# POST #
# #
######################
Connection closed by foreign host.

FTP Kerberisé :

Pour connecter au serveur ftp en utilisant kerberos :

[kitty@ushas kitty]$ ftp -x post


Connected to post.kerb.org.
220 post.kerb.org FTP server (Version 5.60) ready.
334 Using authentication type GSSAPI; ADAT must follow
GSSAPI accepted as authentication type
GSSAPI authentication succeeded
200 Data channel protection level set to private.
Name (post:kitty):
232 GSSAPI user kitty@KERB.ORG is authorized as kitty
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd ISO
250 CWD command successful.
ftp> ls

Page 7 sur 8
Romain REBOTIER CS 530 – TP2 Novembre 2008
Jean-Marc DUFOUR P2009

227 Entering Passive Mode (10,10,22,41,181,173)


150 Opening ASCII mode data connection for /bin/ls.
total 95336
-rw------- 1 labuser 46399488 Jun 15 12:58 cd-puppy.iso
-rw-rw-r-- 1 labuser 51109888 Jun 15 12:58 damnsmall-0.5.2.iso
-rw-rw-r-- 1 labuser 54 Jun 15 12:58 damnsmall-0.5.2.md5.txt
226 Transfer complete.
ftp> mget damnsmall*
mget damnsmall-0.5.2.iso? y
227 Entering Passive Mode (10,10,22,41,181,180)
150 Opening BINARY mode data connection for damnsmall-0.5.2.iso (51109888
bytes).
226 Transfer complete.
51109888 bytes received in 16 seconds (3.1e+03 Kbytes/s)
mget damnsmall-0.5.2.md5.txt? y
227 Entering Passive Mode (10,10,22,41,181,184)
150 Opening BINARY mode data connection for damnsmall-0.5.2.md5.txt (54
bytes).
226 Transfer complete.
54 bytes received in 0.017 seconds (3.2 Kbytes/s)
ftp> quit
221 Goodbye.
[kitty@ushas kitty]$

Page 8 sur 8

Vous aimerez peut-être aussi