
Existen dos niveles de seguridad disponibles en el protocolo de red Common Internet Filesystem (CIFS): user-level (a nivel de usuario) y share-level (a nivel de recurso). La implementación que hace Samba de security mode permite más flexibilidad, ya que proporciona cuatro formas de implementar la seguridad user-level y una forma de implementar share-level:
security = user: exige que los clientes proporcionen un nombre de usuario y una contraseña para conectarse a los recursos compartidos. Las cuentas de usuario de Samba están separadas de las cuentas del sistema, pero el paquete libpam-smbpass sincroniza las cuentas y contraseña del sistema con la base de datos de usuarios de Samba.
security = domain: este modo permite que el servidor Samba se muestre a los clientes Windows como un controlador primario de dominio (Primary Domain Controller, PDC), un controlador secundario de dominio (Backup Domain Controller, BDC) o un servidor de miembros de dominio (Domain Member Server, DMS). Consulte the section called “Samba como controlador de dominio” para más información.
security = ADS: permite que el servidor Samba pueda unirse a un dominio de Active Directory como si fuera un miembro nativo. Consulte the section called “Integración de Samba con Active Directory” para más información.
security = server: this mode is left over from before Samba could become a member server, and, due to some security issues, should not be used. See the Server Security section of the Samba guide for more details.
security = share: permite que los clientes puedan conectarse a los recursos compartidos sin necesidad de proporcionar un nombre de usuario y una contraseña.
El modo de seguridad preferido depende del entorno y lo que el servidor Samba necesite llevar a cabo.
This section will reconfigure the Samba file and print server, from the section called “Servidor de archivos Samba” and the Print Server, to require authentication.
En primer lugar, instalar el paquete libpam-smbpassapplication>, que sincronizar
sudo apt-get install libpam-smbpass
Note
If the Samba Server task was chosen during installation, libpam-smbpass is already installed.
Edite /etc/samba/smb.conf
, y en la sección [share] cambie:
guest ok = no
Finalmente, reinicie Samba para que la nueva configuración tenga efecto:
sudo /etc/init.d/samba restart
Ahora cuando se conecte a los directorios compartidos o impresoras, se le preguntará un nombre de usuario y contraseña.
Note
To map a network drive to the share, “Reconnect at Logon” should be checked, which will require the username and password to be entered just once, at least until the password changes.
Hay varias opciones disponibles para aumentar la seguridad de cada directorio compartido en particular. Usando el ejemplo [share], esta sección cubre algunas opciones comunes.
Groups define a collection of computers or users which have a common level of access to particular network resources and offer a level of granularity in controlling access to such resources. For example, if a group qa is defined and contains the users freda, danika, and rob and a second group support is defined and consists of users danika, jeremy, and vincent, then certain network resources configured to allow access by the qa group will subsequently enable access by freda, danika, and rob, but not jeremy or vincent. Since the user danika belongs to both the qa and support groups, she will be able to access resources configured for access by both groups, whereas all other users will have only access to resources explicitly allowing the group they are part of.
Samba por defecto busca los grupos del sistema local definidos en /etc/group
para determinara que usuarios pertenecen a que grupos. Para más información sobre como añadir o eliminar usuarios de los grupos, veraBásicos.
When defining groups in the Samba configuration file,
/etc/samba/smb.conf
, the recognized syntax
is to preface the group name with an "@" symbol. For example, to define a group
named sysadmin in a certain section of the
/etc/samba/smb.conf
, the group name would be entered as
@sysadmin.
Los permisos de archivos definen los derechos explícitos que un equipo o usuario poseen sobre un directorio, archivo o conjunto de archivos en particular. Tales permisos deben definirse editando archivo el /etc/samba/smb.conf
y especificando los permisos explícitos de un recurso compartido concreto.
For example, for a defined Samba share called share and
the need to give read-only permissions to the
group of users known as qa, while allowing
write permissions to the share by the group called
sysadmin and the user named vincent, then the
/etc/samba/smb.conf
file could be edited to add the
following entries under the [share] entry:
read list = @qa write list = @sysadmin, vincent
Another possible Samba permission is to declare administrative permissions to a particular shared resource. Users having administrative permissions may read, write, or modify any information contained in the resource where the user has been given explicit administrative permissions.
For example, to give the user melissa
administrative permissions to the share
example, the /etc/samba/smb.conf
file would be edited to
add the following line under the [share] entry:
admin users = melissa
Después de editar /etc/samba/smb.conf
, reinicie Samba para que los cambios tengan efecto:
sudo /etc/init.d/samba restart
Note
Para que read list y write list funcionen, el modo de seguridad de Samba no debe estar establecido a security = share.
Ahora que Samba ha sido configurado para limitar qué grupos tienen acceso al directorio compartido, se necesitan actualizar los permisos del sistema de archivos.
Traditional Linux file permissions do not map well to Windows NT Access Control
Lists (ACLs). Fortunately POSIX ACLs are available on Kubuntu servers
providing more fine grained control. For example, to enable ACLs on
/srv
an EXT3 filesystem, edit
/etc/fstab
adding the acl option:
UUID=66bcdd2e-8861-4fb0-b7e4-e61c569fe17d /srv ext3 noatime,relatime,acl 0 1
Ahora vuelva a montar la partición:
sudo mount -v -o remount /srv
Note
The above example assumes /srv
on a separate partition. If /srv
,
or wherever the share path is configured, is part of the /
partition, a reboot may be required.
To match the Samba configuration above, the sysadmin group
will be given read, write, and execute permissions to
/srv/samba/share
, the qa group will be
given read and execute permissions, and the files will be owned by the username
melissa. Enter the following in a terminal:
sudo chown -R melissa /srv/samba/share/ sudo chgrp -R sysadmin /srv/samba/share/ sudo setfacl -R -m g:qa:rx /srv/samba/share/
Note
The setfacl command above gives
execute permissions to all files in the
/srv/samba/share
directory, which may or may not be
desirable.
A Windows client will show that the new file permissions are implemented. See the acl and setfacl man pages for more information on POSIX ACLs.
Kubuntu comes with the AppArmor security module, which provides mandatory access controls. The default AppArmor profile for Samba will need to be adapted to the proper configuration. For more details on using AppArmor, please refer to the wiki
There are default AppArmor profiles for /usr/sbin/smbd
and
/usr/sbin/nmbd
, the Samba daemon binaries, as part of the
apparmor-profiles packages. To install the package,
from a terminal prompt, enter:
sudo apt-get install apparmor-profiles
Note
Este paquete contiene perfiles para distintos binarios.
By default the profiles for smbd and nmbd are in complain mode, allowing Samba to work without modifying the profile, and only logging errors. To place the smbd profile into enforce mode, and have Samba work as expected, the profile will need to be modified to reflect any directories that are shared.
Edite /etc/apparmor.d/usr.sbin.smbd
, añadiendo información para [share] desde el ejemplo de servidor de archivos:
/srv/samba/share/ r, /srv/samba/share/** rwkix,
Ahora ponga el perfil en enforce y recargue:
sudo aa-enforce /usr/sbin/smbd cat /etc/apparmor.d/usr.sbin.smbd | sudo apparmor_parser -r
Ahora se puede leer, escribir y ejecutar archivos en el directorio compartido como normal, y el binario smbd tendrá acceso solamente a los archivos y directorios configurados. Asegúrese de añadir entradas para cada directorio que se configuró para compartir con Samba. Cualquier error será registrado en /var/log/syslog
.
Para ver en profundidad las configuraciones de Samba vea la Colección Samba HOWTO
La guía también está disponible en formato impreso.
Usando Samba, de O'Reilly, también es una buena referencia.
El capítulo 18 de la colección de HOWTOs de Samba está dedicado a la seguridad.
Para más información sobre Samba y ACLs, vea la Página Samba ACLs .