Samba (Español)
From ArchWiki
i18n |
---|
Česky |
Dansk |
Deutsch |
English |
Español |
Italiano |
Română |
Русский |
Türkçe |
简体中文 |
正體中文 |
(Traducción del artículo en inglés en curso)
Contents |
Introducción
Samba es una reimplementación del protocolo de red SMB/CIFS. Facilita el intercambio de ficheros y de impresoras entre sistemas Linux y Windows, o entre sistemas Linux -como una alternativa a Nfs. Se configura fácilmente.
Instalación
Para instalar el servidor Samba, instala el paquete samba
# pacman -S samba
Configuración
Identificado como superusuario (root), copia el fichero por defecto de Samba a /etc/samba/smb.conf
# cp /etc/samba/smb.conf.default /etc/samba/smb.conf
Abre /etc/samba/smb.conf y edítalo según tus necesidades. El fichero está comentado y proporciona varios ejemplos. No debería ser difícil de entender.
El fichero, por defecto, crea una carpeta de intercambio para cada usuario. También crea un intercambio de impresoras.
Iniciando el demonio
Samba puede ser iniciado con
# /etc/rc.d/samba start
Samba normalmente usa FAM para vigilar los cambios en el sistema de ficheros. Necesitarás tener el demonio fam iniciado antes que samba. Una alternativa es usar Gamin
Añade samba a la línea DAEMONS en rc.conf para iniciar el demonio en cada arranque.
Añadiendo usuarios
Para usar Samba necesitarás añadir un usuario:
# smbpasswd -a <user>
El usuario debe tener una cuenta en el servidor. Si el usuario no existe recibirás el error:
Failed to modify password entry for user "<user>"
Puedes añadir un nuevo usuario con adduser
Accediendo a los intercambios Samba
KDE y Gnome pueden navegar por los directorios de intercambio Samba. De este modo, ningún paquete adicional es necesario si usas estos entornos de escritorio. Si, por el contrario, tienes pensado el intercambio desde una consola de comandos, necesitarás un paquete más.
Desde Gnome
En una ventana de Nautilus, presiona ctrl+L o ve al menú "Go-Ir" y selecciona "Lugar..." (N.T. no tengo Gnome, si esto es otra palabra que alguien lo edite si le place claro :) ). Cualquiera de las dos acciones te permitirá introducir smb://servername/share en la barra que aparece Enter.
smb://servername/sharename
or
smb://192.168.1.5/sharename
En KDE, es prácticamente igual (N.T. ídem). Para una interfaz gráfica necesitas instalar el paquete "kdenetwork-filesharing" desde el repositorio Extra.
Desde una consola
Puedes también usar smbclient para navegar por la red desde la consola.
$ smbclient -L <hostname> -U%
Listará los directorios públicos del servidor
Mounting a Samba Share
To manually mount a share from the shell:
# mount.cifs //<hostname>/<share> <mount_point> -o user=<username>,password=<password>
To allow a normal user to mount and unmount a Samba share you can add setuid root to /sbin/mount.cifs. An alternative is to use the smbnetfs package.
Adding a Share to fstab
You can add a line to fstab like this:
//<hostname>/<share> <mount_point> cifs credentials=<credentials_file>,rw,user,noauto 0 0
Since fstab is readable by all users, we don't want to put our Samba password in this file. In this case we can use a credentials file that is only readable by you. This is a simple text file that contains:
username=<username> password=<password>
The user option of the fstab line allows the owner of the <mount_point> to mount and unmount the share. The noauto option disables mounting at boot.
If you are adding a Samba share to fstab, you should also add the netfs daemon to rc.conf, somewhere after the network daemon. The netfs daemon will mount network partitions at boot and, more importantly, unmount network partitions at shutdown. Even if you are using the noauto option in fstab you should add the netfs daemon. Without it any network share that is mounted when you shutdown will cause the network daemon to wait for the connection to time out, consideribly extending your shutdown time.
Share files for your LAN without user and password
Edit default /etc/samba/smb.conf on the following lines:
security = user
to
security = share
If you want to restrict the shares data to a specific interface replace
; interfaces = 192.168.12.2/24 192.168.13.2/24
to (replace eth0 to local network you want share to)
interfaces = lo eth0 bind interfaces only = true
if you want to edit the account that access the shares, edit the following line:
; guest account = nobody
The last step is to create share directory (for write access make writable = yes):
[Public Share] path = /path/to/public/share available = yes browsable = yes public = yes writable = no
Sample configuration file
The configuration that worked for me:
[global] workgroup = WORKGROUP server string = Samba Server netbios name = PC_NAME security = share ; the line below is important! If you have permission issues make sure the user here is the same as the user of the folder you want to share guest account = mark username map = /etc/samba/smbusers name resolve order = hosts wins bcast wins support = no
[public] comment = Public Share path = /path/to/public/share available = yes browsable = yes public = yes writable = no
Troubleshooting
If you are having trouble accessing a password protected share from Windows, try adding this to the /etc/samba/smb.conf Suggestion found here
[global] # THE LANMAN FIX client lanman auth = yes client ntlmv2 auth = no
See Also
More Resources
- Samba Samba (German) (archlinux.de)
- Official samba website
- Samba: An Introduction