A continuación vamos a ver kerberos con ssh, deberemos usar el fichero /etc/hosts para añadir los equipos o usar el DNS. Para ver que nuestro DNS esta funcionado correctamente ejecutamos el comando «hostname -f»:
root@targaryen:/home/debian# hostname -f targaryen.manu.gonzalonazareno.org root@targaryen:/home/debian# root@stark:/home/debian# hostname -f stark.manu.gonzalonazareno.org root@stark:/home/debian#
En primer lugar debemos de poner los equipos que tengan la misma hora ya que podría darnos problemas a la larga. Lo que debemos de hacer es por ejemplo instalar el paquete «ntpdate».
Una ve hayamos hecho esto procederemos con kerberos lo primero que haremos es instalarlo en el servidor que en este caso es Targaryen.
root@targaryen:/home/debian# apt-get install krb5-kdc krb5-admin-server
Durante la instalación nos aparecerán ventanas dentro de la terminal para que completemos y aceptemos:
Cuando acabe la isntalación es normal que nos salgar mensajes de error ya que no lo hemos configurado aun:
Ficheros de configuración.
Posteriormente lo que vamos a hacer es configurar el fichero «/etc/krb5kdc/kdc.conf» haciendo que solo escuche por el puerto 88:
[kdcdefaults] kdc_ports = 88
Luego nos vamos al fichero «/etc/default/krb5-kdc» y añadimos lo siguiente:
# Automatically generated. Only the value of DAEMON_ARGS will be preserved. # If you change anything in this file other than DAEMON_ARGS, first run # dpkg-reconfigure krb5-kdc and disable managing the KDC configuration with # debconf. Otherwise, changes will be overwritten. KRB4_MODE=disable RUN_KRB524D=false
Luego nos vamos al fichero de configuración y comprobamos de que tiene que estar parecido al siguiente:
[libdefaults] default_realm = MANU.GONZALONAZARENO.ORG # The following krb5.conf variables are only for MIT Kerberos. krb4_config = /etc/krb.conf krb4_realms = /etc/krb.realms kdc_timesync = 1 ccache_type = 4 forwardable = true proxiable = true # The following encryption type specification will be used by MIT Kerberos # if uncommented. In general, the defaults in the MIT Kerberos code are # correct and overriding these specifications only serves to disable new # encryption types as they are added, creating interoperability problems. # # Thie only time when you might need to uncomment these lines and change # the enctypes is if you have local software that will break on ticket # caches containing ticket encryption types it doesn't know about (such as # old versions of Sun Java). # default_tgs_enctypes = des3-hmac-sha1 # default_tkt_enctypes = des3-hmac-sha1 # permitted_enctypes = des3-hmac-sha1 # The following libdefaults parameters are only for Heimdal Kerberos. v4_instance_resolve = false v4_name_convert = { host = { rcmd = host ftp = ftp } plain = { something = something-else } } fcc-mit-ticketflags = true [realms] MANU.GONZALONAZARENO.ORG = { kdc = targaryen.manu.gonzalonazareno.org admin_server = targaryen.manu.gonzalonazareno.org } ATHENA.MIT.EDU = { kdc = kerberos.mit.edu:88 kdc = kerberos-1.mit.edu:88 kdc = kerberos-2.mit.edu:88 admin_server = kerberos.mit.edu default_domain = mit.edu
solo tenemos que añadir debajo del todo en «[domain_realm]» y añadimos las siguientes líneas con nuestro nombre de dominio:
[domain_realm] .manu.gonzalonazareno.org = MANU.GONZALONAZARENO.ORG manu.gonzalonazareno.org = MANU.GONZALONAZARENO.ORG
A continuación vamos a ejecutar el comando «krb5_newrealm», durante la ejecución nos pedirá la contraseña, la introducimos y terminamos:
root@targaryen:/home/debian# krb5_newrealm This script should be run on the master KDC/admin server to initialize a Kerberos realm. It will ask you to type in a master key password. This password will be used to generate a key that is stored in /etc/krb5kdc/stash. You should try to remember this password, but it is much more important that it be a strong password than that it be remembered. However, if you lose the password and /etc/krb5kdc/stash, you cannot decrypt your Kerberos database. Loading random data Initializing database '/var/lib/krb5kdc/principal' for realm 'MANU.GONZALONAZARENO.ORG', master key name 'K/M@MANU.GONZALONAZARENO.ORG' 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: [ ok ] Starting Kerberos KDC: krb5kdc. [ ok ] Starting Kerberos administrative servers: kadmind. Now that your realm is set up you may wish to create an administrative principal using the addprinc subcommand of the kadmin.local program. Then, this principal can be added to /etc/krb5kdc/kadm5.acl so that you can use the kadmin program on other computers. Kerberos admin principals usually belong to a single user and end in /admin. For example, if jruser is a Kerberos administrator, then in addition to the normal jruser principal, a jruser/admin principal should be created. Don't forget to set up DNS information so your clients can find your KDC and admin servers. Doing so is documented in the administration guide. root@targaryen:/home/debian#
Una vez hecho esto arrancamos los servicios, hacemos un restart por si acaso estuvieran arrancados ya:
root@targaryen:/home/debian# /etc/init.d/krb5-admin-server restart [ ok ] Restarting Kerberos administrative servers: kadmind. root@targaryen:/home/debian# /etc/init.d/krb5-kdc restart [ ok ] Restarting Kerberos KDC: krb5kdc. root@targaryen:/home/debian#
A continuación debemos de crear un usuaruio, ya que kerberos no trae ninguno excepto el administrado y solo es accesible desde local:
root@targaryen:/home/debian# kadmin.local Authenticating as principal root/admin@MANU.GONZALONAZARENO.ORG with password. kadmin.local: add_principal manuelj/admin@MANU.GONZALONAZARENO.ORG WARNING: no policy specified for manuelj/admin@MANU.GONZALONAZARENO.ORG; defaulting to no policy Enter password for principal "manuelj/admin@MANU.GONZALONAZARENO.ORG": Re-enter password for principal "manuelj/admin@MANU.GONZALONAZARENO.ORG": Principal "manuelj/admin@MANU.GONZALONAZARENO.ORG" created. kadmin.local:
Una vez creado para que tenga permisos sobre el dominio el usuario que acabamos de crear nos vamos al fichero «/etc/krb5kdc/kadm5.acl» que es una ACL (Lista de Control de Acceso) y descomentamos la línea «*/admin *» quedando de la siguiente forma:
# This file Is the access control list for krb5 administration. # When this file is edited run /etc/init.d/krb5-admin-server restart to activate # One common way to set up Kerberos administration is to allow any principal # ending in /admin is given full administrative rights. # To enable this, uncomment the following line: */admin *
Hecho ya esto ahora vamos a autenticarnos con el usuario que acabamos de crear:
root@targaryen:/home/debian# kinit manuelj/admin
Password for manuelj/admin@MANU.GONZALONAZARENO.ORG:
root@targaryen:/home/debian#
Configuración del cliente:
Una vez terminada la configuración en el servidor nos vamos al cliente que en este caso es Stark. En primero lugar debemos de instalar los paquetes necesarios:
root@stark:/home/debian# apt-get install krb5-user krb5-config
En las ventanas emergentes que nos salen durante la instalación vemos que es igual que cuando lo instalamos en el servidor, debemo de poner lo mismo, es decir, el dominio manu.gonzalonazareno.org y targaryen.manu.gonzalonazareno.org.
Lo mismo pasa con el fichero «/etc/krb5.conf» debemos dejarlo exactamente como esta en el servidor.
Definir clientes en el servidor:
Luego debemos de definir el servidor y el cliente con «kadmin.local»:
kadmin.local: add_principal -randkey host/targaryen.manu.gonzalonazareno.org@MANU.GONZALONAZARENO.ORG WARNING: no policy specified for host/targaryen.manu.gonzalonazareno.org@MANU.GONZALONAZARENO.ORG; defaulting to no policy Principal "host/targaryen.manu.gonzalonazareno.org@MANU.GONZALONAZARENO.ORG" created. kadmin.local: add_principal -randkey host/stark.manu.gonzalonazareno.org@MANU.GONZALONAZARENO.ORG WARNING: no policy specified for host/stark.manu.gonzalonazareno.org@MANU.GONZALONAZARENO.ORG; defaulting to no policy Principal "host/stark.manu.gonzalonazareno.org@MANU.GONZALONAZARENO.ORG" created. kadmin.local:
Y a continuación los exportamos a Stark, lo hemos hecho por «fpt» pero se puede hacer también por «scp»:
root@targaryen:/tmp# ftp ftp.iesgn.org Connected to ftp.iesgn.org. 220 ProFTPD 1.3.4a Server (Servidor FTP) [10.0.0.54] Name (ftp.iesgn.org:debian): user_informatica 331 Password required for user_informatica Password: 230 User user_informatica logged in Remote system type is UNIX. Using binary mode to transfer files. ftp> put krb5.keytab. local: krb5.keytab. remote: krb5.keytab. 200 PORT command successful 150 Opening BINARY mode data connection for krb5.keytab. 226 Transfer complete 414 bytes sent in 0.00 secs (1981.8 kB/s) ftp> root@stark:/home/debian# ftp ftp.iesgn.org Connected to ftp.iesgn.org. 220 ProFTPD 1.3.4a Server (Servidor FTP) [10.0.0.54] Name (ftp.iesgn.org:debian): user_informatica 331 Password required for user_informatica Password: 230 User user_informatica logged in Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 200 PORT command successful 150 Opening ASCII mode data connection for file list -rw-r--r-- 1 user_informatica user_informatica 97 Jan 25 20:17 index.html -rw-r--r-- 1 user_informatica user_informatica 414 Jan 25 20:27 krb5.keytab. 226 Transfer complete ftp> get krb5.keytab. local: krb5.keytab. remote: krb5.keytab. 200 PORT command successful 150 Opening BINARY mode data connection for krb5.keytab. (414 bytes) 226 Transfer complete 414 bytes received in 0.00 secs (1591.7 kB/s) ftp>
y lo movemos a la carperta «/etc/» de Stark y cambiamos los permisos y el propietario tanto en Targaryen como Stark:
root@stark:/home/debian# chmod 400 /etc/krb5.keytab root@stark:/home/debian# chown sshd:ssh /etc/krb5.keytab root@stark:/home/debian# root@targaryen:/home/debian# chmod 400 /etc/krb5.keytab root@targaryen:/home/debian# chown sshd:ssh /etc/krb5.keytab root@targaryen:/home/debian#
Y para terminar la configuración debemos de editar los siguientes ficheros:
-/etc/ssh/sshd_config
# GSSAPI options GSSAPIAuthentication yes GSSAPICleanupCredentials yes
-/etc/ssh/ssh_config
# PasswordAuthentication yes # HostbasedAuthentication no GSSAPIAuthentication yes GSSAPIDelegateCredentials yes # GSSAPIKeyExchange no # GSSAPITrustDNS no
Reiniciamos ssh:
root@targaryen:/home/debian# service ssh restart [ ok ] Restarting OpenBSD Secure Shell server: sshd. root@targaryen:/home/debian# root@stark:/home/debian# service ssh restart [ ok ] Restarting OpenBSD Secure Shell server: sshd. root@stark:/home/debian#
Por ultimo nos vamos a la maquina Stark y nos logueamos en la maquina Targaryan, comprobando que no se nos pide contraseña cuando lo hacemos:
root@stark:/home/debian# kinit manuelj Password for manuelj@MANU.GONZALONAZARENO.ORG: root@stark:/home/debian# ssh manuelj@targaryen ssh: Could not resolve hostname targaryen: Name or service not known root@stark:/home/debian# ssh manuelj@targaryen.manu.gonzalonazareno.org The authenticity of host 'targaryen.manu.gonzalonazareno.org (172.22.200.53)' can't be established. ECDSA key fingerprint is f0:41:7b:4d:75:cb:04:73:45:22:de:99:ac:22:da:2b. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'targaryen.manu.gonzalonazareno.org' (ECDSA) to the list of known hosts. Linux targaryen 3.2.0-4-amd64 #1 SMP Debian 3.2.63-2+deb7u1 x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Wed Jan 28 16:45:16 2015 from 172.22.200.53 manuelj@targaryen:~$