Lihuen
RSSRSS AtomAtom

Diferencia entre revisiones de «Compartiendo usuarios en un dominio Windows preexistente»

(Recursos)
Línea 1: Línea 1:
Instalando winbind y libpam-mount
+
=Compartiendo usuarios y sus carpetas personales=
  
Utilizamos winbind para autentificarse en el dominio Windows y libpam-mount para montar los recusros compartidos del dominio automáticamente.
+
==Instalando winbind y libpam-mount==
 +
 
 +
Utilizamos winbind para autenticarse en el dominio Windows y libpam-mount para montar los recursos compartidos del dominio automáticamente.
  
 
  # apt-get install winbind
 
  # apt-get install winbind
 
  # apt-get install libpam-mount
 
  # apt-get install libpam-mount
  
instalar pam_cups http://sourceforge.net/projects/pam-cups/ (Antes de compilar hay que parcharlo, el parche está más abajo) bajar http://www.geocities.com/wronski12/posix_ipc/libmqueue-4.41.tar.gz.
+
==Configuración de Windbind en nsswitch.conf==
 
+
 
+
 
/etc/nsswitch.conf
 
/etc/nsswitch.conf
 
  # /etc/nsswitch.conf
 
  # /etc/nsswitch.conf
Línea 31: Línea 31:
  
  
Modificar el archivo /etc/pam.d/common-session
+
==Configuración de PAM==
 +
Hay que modificar los siguientes archivos
 +
*/etc/pam.d/common-account
 +
account sufficient pam_winbind.so
 +
account required pam_unix.so
  
Contenido:
+
*/etc/pam.d/common-auth
#
+
  auth required pam_cups.so
# /etc/pam.d/common-session - session-related modules common to all services
+
  auth required pam_mount.so use_first_pass
  #
+
  auth sufficient /lib/security/pam_winbind.so use_first_pass
  # This file is included from other service-specific PAM config files,
+
  auth required pam_unix.so nullok_secure use_first_pass
  # and should contain a list of modules that define tasks to be performed
+
 
  # at the start and end of sessions of *any* kind (both interactive and
+
*/etc/pam.d/common-session
# non-interactive). The default is pam_unix.
+
#
+
 
  session required pam_unix.so nullok_secure
 
  session required pam_unix.so nullok_secure
 
  session required pam_mkhomedir.so skel=/etc/skel umask=0022
 
  session required pam_mkhomedir.so skel=/etc/skel umask=0022
Línea 47: Línea 49:
 
  session optional pam_mount.so  
 
  session optional pam_mount.so  
  
Modificar el archivo /etc/pam.d/common-account
 
Contenido:
 
#
 
# /etc/pam.d/common-account - authorization settings common to all services
 
#
 
# This file is included from other service-specific PAM config files,
 
# and should contain a list of the authorization modules that define
 
# the central access policy for use on the system. The default is to
 
# only deny service to users whose accounts are expired in /etc/shadow.
 
#
 
account sufficient pam_winbind.so
 
account required pam_unix.so
 
  
  
 
+
==Configuración de Samba para que se una al dominio==
Modificar el archivo /etc/pam.d/common-auth
+
Contenido:
+
#
+
# /etc/pam.d/common-auth - authentication settings common to all services
+
#
+
# This file is included from other service-specific PAM config files,
+
# and should contain a list of the authentication modules that define
+
# the central authentication scheme for use on the system
+
# (e.g., /etc/shadow, LDAP, Kerberos, etc.). The default is to use the
+
# traditional Unix authentication mechanisms.
+
#
+
#auth required pam_mount.so
+
auth required pam_cups.so
+
auth required pam_mount.so use_first_pass
+
auth sufficient /lib/security/pam_winbind.so use_first_pass
+
auth required pam_unix.so nullok_secure use_first_pass
+
 
+
 
Agregar en el archivo original de configuración de samba /etc/smb/smb.conf lo siguiente
 
Agregar en el archivo original de configuración de samba /etc/smb/smb.conf lo siguiente
 
  [global]
 
  [global]
Línea 85: Línea 58:
 
  # use gids from 10000 to 20000 for domain groups
 
  # use gids from 10000 to 20000 for domain groups
 
  idmap gid = 10000-20000  
 
  idmap gid = 10000-20000  
  template homedir = /home/winnt/%D/%U
+
  #template homedir = /home/winnt/%D/%U
 +
template homedir = /home/%U
 
  workgroup = NOMBREDELDOMINIO
 
  workgroup = NOMBREDELDOMINIO
 
  Agregando la máquina al dominio
 
  Agregando la máquina al dominio
Línea 107: Línea 81:
  
 
Este archivo dependerá de que es lo que queremos montar, dentro del mismo archivo están todas las opciones documentadas, sólo muestro lo necesario.
 
Este archivo dependerá de que es lo que queremos montar, dentro del mismo archivo están todas las opciones documentadas, sólo muestro lo necesario.
 
+
*Agregar en /etc/security/pam_mount.conf
Para adaptarlo a nuestro dominio cambiar la palabra ?reemplazar? por los parámetros apropiados
+
 
+
# Turn on if you want to debug why some volume cannot be mounted etc.
+
# This can be overriden by user's local configuration
+
#
+
# Format: debug [ 1 | 0 ]
+
# Local user configuration can override this.
+
+
debug 0
+
mkmountpoint 1
+
# Loopback device to use to run fsck on loopback filesystems.
+
fsckloop /dev/loop7
+
# Users' local configuration file (if there is none, comment out this
+
# parameter). Will be read as ~/<file>
+
#
+
# Note: you must include either options_allow or options_deny to use
+
# this directive. I recommend also including options_require.
+
#
+
# Individual users may define additional volumes to mount if allowed
+
# by pam_mount.conf (usually ~/.pam_mount.conf). The volume keyword is
+
# the only valid keyword in these per-user configuration files. If the
+
# luserconf parameter is set in pam_mount.conf, allowing user-defined
+
# volume, then users may mount and unmount any volumes they specify.
+
# The mount operation is executed under the user account, not with
+
# root permissions.
+
# IMPORTANT: right now only smb and ncp mounts work in ~/.pam_mount.conf
+
# since they do not require root privileges! All other mount types
+
# have to be in the global configuration file.
+
# Please only file bugs about this if you can exactly show and prevent
+
# the security implications of user-specified mount commands.
+
#
+
# Format: luserconf <file>
+
luserconf .pam_mount.conf
+
+
# These directives determine which options may be specified in a user config
+
# file (luserconf). You must include one of these directives if you have a
+
# luserconf directive. You may not include both directives.
+
#
+
# If you have an options_allow directive, then the options listed in that
+
# directive wil be allowed, and all others rejected. If you have an
+
# options_deny directive, then the options listed will be denied, and all others
+
# permitted.
+
#
+
# You may use the wildcard '*' to match all options.
+
#
+
options_allow nosuid,nodev,loop,encryption
+
options_deny suid,dev
+
# options_allow *
+
# options_deny *
+
#
+
# I recommend not permitting the suid and dev options.
+
# The options listed in this directive are required for all volumes from a
+
# user config file. That is, any volume specified in a user config file that
+
# does not include these options will be ignored.
+
#
+
# Note: you must make sure that a required option is permitted (either by
+
# including it in options_allow, or by not including it in options_deny).
+
#
+
# I recommend requiring at least nosuid and nodev.
+
#
+
# This is ignored completely if the volume is configured to get its options
+
# and mount point from /etc/fstab.
+
#
+
options_require nosuid,nodev
+
+
# Commands to mount/unmount volumes. They can take parameters, as shown.
+
#
+
# If you change the -p0 argument for lclmount, you'll need to modify the
+
# source in mount.c (it sends the password to the stdin file descriptor
+
# of the child process -- look for STDIN_FILENO).
+
+
lsof /usr/sbin/lsof %(MNTPT)
+
fsck /sbin/fsck -p %(FSCKTARGET)
+
losetup /sbin/losetup -p0 "%(before=\"-e\" CIPHER)" "%(before=\"-k\" KEYBITS)" %(FSCKLOOP) %(VOLUME)
+
unlosetup /sbin/losetup -d %(FSCKLOOP)
+
cifsmount /bin/mount -t cifs //%(SERVER)/%(VOLUME) %(MNTPT) -o "username=%(USER)%(before=\",\" OPTIONS)"
+
smbmount /usr/bin/smbmount //%(SERVER)/%(VOLUME) %(MNTPT) -o "username=%(USER)%(before=\",\" OPTIONS)"
+
ncpmount /usr/bin/ncpmount %(SERVER)/%(USER) %(MNTPT) -o "pass-fd=0,volume=%(VOLUME)%(before=\",\" OPTIONS)"
+
smbumount /usr/bin/smbumount %(MNTPT)
+
ncpumount /usr/bin/ncpumount %(MNTPT)
+
+
# Linux supports lazy unmounting (-l). May be dangerous for encrypted volumes.
+
# May also break loopback mounts because loopback devices are not freed.
+
# Need to unmount mount point not volume to support SMB mounts, etc.
+
umount /bin/umount %(MNTPT)
+
# On OpenBSD try "/usr/local/bin/mount_ehd" (included in pam_mount package).
+
lclmount /bin/mount -p0 %(VOLUME) %(MNTPT) "%(before=\"-o\" OPTIONS)"
+
cryptmount /bin/mount -t crypt "%(before=\"-o\" OPTIONS)" %(VOLUME) %(MNTPT)
+
nfsmount /bin/mount %(SERVER):%(VOLUME) %(MNTPT) "%(before=\"-o\" OPTIONS)"
+
# --bind may be a Linuxism. FIXME: find BSD equivalent.
+
+
mntagain /bin/mount --bind %(PREVMNTPT) %(MNTPT)
+
#mntcheck /bin/mount # For BSD's (don't have /etc/mtab)
+
pmvarrun /usr/sbin/pmvarrun -u %(USER) -d -o %(OPERATION)
+
+
# Volumes that will be mounted when user triggers pam_mount module
+
# (usually at login).
+
#
+
# Format:
+
# volume <user> [smb|ncp|nfs|local] <server> <volume> <mount point> <mount options> <fs key cipher> <fs key path>
+
#
+
# Note that if the mount command has specified an option, eg %(KEYBITS)
+
# and you don't specify a value, a warning is printed in the log. The
+
# warning can usually be ignored, except when the option is mandatory.
+
#
+
# General examples:
+
#
+
# smb mounts require the "smbfs" Debian package
+
# smb mounts work also in user-specified config file ~/.pam_mount.conf
+
# volume user smb krueger public /home/user/krueger - - -
+
#
+
# ncp mounts require the "ncpfs" Debian package
+
# ncp mounts work also in user-specified config file ~/.pam_mount.conf
+
# volume user ncp krueger public /home/user/krueger user=user.context - -
+
#
+
# Linux encrypted home directory examples, using dm_crypt:
+
#
+
# crypt mounts require a kernel with CONFIG_BLK_DEV_DM and CONFIG_DM_CRYPT
+
# enabled as well as all the used ciphers (eg. CONFIG_CRYPTO_AES_586,
+
# CONFIG_CRYPTO_TWOFISH, etc.)
+
# crypt mounts require the "cryptsetup" Debian package.
+
# crypt mounts must be in the global config file /etc/security/pam_mount.conf
+
# volume user crypt - /dev/sda2 /home/user cipher=aes aes-256-ecb /home/user.key
+
#
+
# Linux encrypted home directory examples, using cryptoloop:
+
#
+
# cryptoloop mounts require a kernel with CONFIG_BLK_DEV_CRYPTOLOOP enabled
+
# cryptoloop mounts must be in the global config file
+
# /etc/security/pam_mount.conf
+
# volume user local - /dev/hda123 /home/user loop,encryption=aes - -
+
# volume user local - /home/user.img /home/user loop,user,exec,encryption=aes,keybits=256 - -
+
# volume user local - /home/user.img - - - -
+
# volume user local - /home/user.img - - aes-256-ecb /home/user4.key
+
#
+
# The last two examples need a line like the following in
+
# /etc/fstab:
+
#
+
# /home/user4.img /home/user4 xfs user,loop,encryption=aes,keybits=256,noauto 0 0
+
#
+
+
# OpenBSD encrypted home directory example (see also lclmount above):
+
# volume user local - /home/user.img /home/user svnd0 - -
+
#
+
# Volatile tmpfs mount with restricted size
+
# (thanks to Mike Hommey for this example)
+
#
+
# volume test local - /tmpfs/test /home/test "size=10M,uid=test,gid=users,mode=0700 -t tmpfs" - -
+
#
+
# Details:
+
# Local user configuration (~/.pam_mount.conf) can extend this.
+
#
+
# If there are no servers, mount options, fs key ciphers, etc. you must
+
# supply a "-"
+
#
+
# See http://www.tldp.org/HOWTO/Loopback-Encrypted-Filesystem-HOWTO.html
+
# to learn how to create a encrypted loopback filesystem.
+
#
+
# If the volume's password is different than the user's login password,
+
# the following technique may be used (see also README):
+
#
+
# 1. Create a file containing the volume's password (FS key). If you are
+
# using pam_mount to mount an loopback encrypted volume, this password
+
# should may generated by /dev/urandom.
+
#
+
# Simple example:
+
# echo <volume password> | openssl enc -aes-256-ecb > /home/user.key
+
# Encrypt this file using the user's login password as the key.
+
#
+
# Verbose loopback encrypted volume example:
+
# a. dd if=/dev/urandom of=/home/user.img bs=1M count=<image size in MB>
+
# b. dd if=/dev/urandom bs=1c count=<keysize / 8> | openssl enc \
+
# -<fs key cipher> > /home/user.key
+
# Encrypt this file using the user's login password as the key.
+
# c. openssl enc -d -<fs key cipher> -in /home/user.key | losetup -e aes \
+
# -k <keysize> -p0 /dev/loop0 /home/user.img
+
# d. mkfs -t ext2 /dev/loop0
+
# e. umount /dev/loop0
+
# f. losetup -d /dev/loop0
+
#
+
# 3. In pam_mount.conf:
+
# a. Set the fs key cipher variable to the cipher used (ie: aes-256-ecb).
+
# b. Set the fs key path variable to the key's path (ie: /home/user.key)
+
# 4. If a user changes his login password, regenerate the efsk that
+
# was created in step 1b. A script named passwdehd is provided to do this.
+
#
+
# If fs_key_cipher is -, then the user's login password is also the volume's
+
# password.
+
# Template (or wildcard) volumes
+
#
+
# If user is "*", "&" will be replaced by name of the user logging on in the
+
# volume, mount point, mount options and fs key path fields. "~/*" will be
+
# replaced with "<user's homedir>/*."
+
#
+
# volume * smb krueger & /home/& uid=&,gid=&,dmask=0750 - -
+
# volume * smb krueger homes /home/&/remote - - -
+
# volume * local - /home/&.img - - aes-256-ecb /etc/ehd/&
+
+
# Windows 2000, which requires a domain specified, example (thanks John Knox):
+
# volume * smb viper & /home/& uid=&,gid=&,dmask=0750,workgroup=WINDOWS_DOMAIN - -
+
 
  volume * smb reemplazarFILESERVER reemplazarRECURSO /home/winnt/& uid=&,gid=&,dmask=0750,workgroup=reemplazarDOMINIO - -
 
  volume * smb reemplazarFILESERVER reemplazarRECURSO /home/winnt/& uid=&,gid=&,dmask=0750,workgroup=reemplazarDOMINIO - -
 
# An NCP example:
 
# volume user ncp SERVER /USERS/Department/user /home/user user=user.full.context,uid=user,gid=user,symlinks - -
 
  
 
=Para utilizar las impresoras del dominio=
 
=Para utilizar las impresoras del dominio=
  
 
Vamos a instalar pam_cups que lo que hace básicamente es cachear las credenciales y presentarlas cada vez que se precisa interactuar con las colas definidas en cupsys.
 
Vamos a instalar pam_cups que lo que hace básicamente es cachear las credenciales y presentarlas cada vez que se precisa interactuar con las colas definidas en cupsys.
 +
 +
instalar pam_cups http://sourceforge.net/projects/pam-cups/ (Antes de compilar hay que parcharlo, el parche está más abajo) bajar http://www.geocities.com/wronski12/posix_ipc/libmqueue-4.41.tar.gz.
  
 
Hay que bajar http://sourceforge.net/projects/pam-cups/ descomprimirlo, configurarlo, compilarlo e instalarlo.
 
Hay que bajar http://sourceforge.net/projects/pam-cups/ descomprimirlo, configurarlo, compilarlo e instalarlo.

Revisión de 10:33 28 sep 2007

Compartiendo usuarios y sus carpetas personales

Instalando winbind y libpam-mount

Utilizamos winbind para autenticarse en el dominio Windows y libpam-mount para montar los recursos compartidos del dominio automáticamente.

# apt-get install winbind
# apt-get install libpam-mount

Configuración de Windbind en nsswitch.conf

/etc/nsswitch.conf

# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         compat winbind
group:          compat winbind
shadow:         compat

hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis


Configuración de PAM

Hay que modificar los siguientes archivos

  • /etc/pam.d/common-account
account sufficient pam_winbind.so
account required pam_unix.so
  • /etc/pam.d/common-auth
auth required pam_cups.so
auth required pam_mount.so use_first_pass
auth sufficient /lib/security/pam_winbind.so use_first_pass
auth required pam_unix.so nullok_secure use_first_pass 
  • /etc/pam.d/common-session
session required pam_unix.so nullok_secure
session required pam_mkhomedir.so skel=/etc/skel umask=0022
session optional pam_cups.so min_uid=10000
session optional pam_mount.so 


Configuración de Samba para que se una al dominio

Agregar en el archivo original de configuración de samba /etc/smb/smb.conf lo siguiente

[global]
# use uids from 10000 to 20000 for domain users
idmap uid = 10000-20000
# use gids from 10000 to 20000 for domain groups
idmap gid = 10000-20000 
#template homedir = /home/winnt/%D/%U
template homedir = /home/%U
workgroup = NOMBREDELDOMINIO
Agregando la máquina al dominio

Una vez que se completa la configuración de samba, hay que agregar la máquina al dominio: Primero reiniciamos el samba y el winbind :

# /etc/init.d/samba restart
# /etc/init.d/winbind restart

Y después lo agregamos al dominio:

# net join -U administrador dominio


Nos va a pedir el password de administrador del dominio lo introducimos y LISTO, estamos dentro del dominio, hacer un "getent passwd" desde la linea de comando para comprobar que devuelva la lista de los usuarios del dominio


Montando automáticamente los archivos compartidos

Modificamos el archivo /etc/security/pam_mount.conf

Para montar automáticamente los archivos compartidos del dominio una vez que los usuarios se loguean y desmontarlos una vez que se desloguean del sistema:

Este archivo dependerá de que es lo que queremos montar, dentro del mismo archivo están todas las opciones documentadas, sólo muestro lo necesario.

  • Agregar en /etc/security/pam_mount.conf
volume * smb reemplazarFILESERVER reemplazarRECURSO /home/winnt/& uid=&,gid=&,dmask=0750,workgroup=reemplazarDOMINIO - -

Para utilizar las impresoras del dominio

Vamos a instalar pam_cups que lo que hace básicamente es cachear las credenciales y presentarlas cada vez que se precisa interactuar con las colas definidas en cupsys.

instalar pam_cups http://sourceforge.net/projects/pam-cups/ (Antes de compilar hay que parcharlo, el parche está más abajo) bajar http://www.geocities.com/wronski12/posix_ipc/libmqueue-4.41.tar.gz.

Hay que bajar http://sourceforge.net/projects/pam-cups/ descomprimirlo, configurarlo, compilarlo e instalarlo. Antes de compilarlo en Debian hay que parchearlo para que compile, porqeu sino da error, el patch lo adjunto mas abajo.

Hay que generar el libmqueue.so, para eso, bajar libmqueue de la red, cualquier busqueda en google lo encuentra, compilarlo e instalarlo. Yo lo baje de http://www.geocities.com/wronski12/posix_ipc/libmqueue-4.41.tar.gz.

Generar el link simbólico /usr/lib/cups/backend/smb que apunta a /usr/bin/pam_cups_spool.

# ln -s /usr/bin/pam_cups_spool /usr/lib/cups/backend/smb

(Ojo que probablemente exista, estonces nos va a dar error, hay que borrar el link anterior, que apunta a la cola de samba por defecto)

Modificar el archivo /etc/init.d/cupscd Contenido:

#!/bin/sh
#
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/sbin/cupscd
OPTIONS=""

case "$1" in
start)
    echo -n "Starting cups cacher: cupscd "
    if start-stop-daemon --quiet --stop --signal 0 --exec $DAEMON
    then
        echo "[already running]"
    else
        /sbin/start-stop-daemon --start --quiet --exec $DAEMON -- $OPTIONS
        echo "."
    fi
    ;;
stop)
    echo -n "Stopping cups cacher: cupscd "
    if start-stop-daemon --quiet --stop --signal 0 --exec $DAEMON
    then
        start-stop-daemon --quiet --stop --exec $DAEMON
        echo "."
    else
        echo "[not running]";
    fi
    ;;
force-reload|restart)
    $0 stop
    sleep 1
    $0 start
    ;;
*)
    echo "Usage: /etc/init.d/cupscd {start|stop|restart|force-reload}"
    exit 1
esac

exit 0

Modificar el archivo /etc/cups/printers.conf Contenido:

<DefaultPrinter printer>
Info .
Location reemplazarDESCRIPCIONDELAUBICACION
DeviceURI smb://reemplazarPRINTERSERVER/reemplazarPRINTERNAME
State Idle
Accepting Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
</Printer> 


El pam_cups principalmente generara: /lib/security/pam_cups.so /usr/sbin/cupscd /usr/bin/pam_cups_spool /usr/lib/cups/backend/smb

Para que arranque siempre el cupscd, hacer un "update-rc.d cupscd defaults"

Recursos

http://foss.stat.unipd.it/mediawiki/index.php/Debian_Client_in_a_Samba_Domain

http://www.geocities.com/wronski12/posix_ipc/index.html

http://www.samba.org