Friday, April 25, 2014

Ubuntu - Create a Samba Network share

Install Samba package
# apt-get update
# apt-get install samba

Set a password for user in Samba
I assume you will mount samba network share directory as root
$ sudo su -
# smbpasswd
or you can
$ sudo smbpasswd -a root

Notice: Samba uses a separate set of passwords than the standard Linux system accounts, so you will need to create a Samba password.

Create a share directory
# mkdir /share/lxu

Edit smb.conf file
Make a copy of the original smb.conf file
# cp /etc/samba/smb.conf /etc/samba/smb.conf-orig
# vi /etc/samba/smb.conf

At least enable "security = user" for security reasons.

Add the following to the end of the file:
[lxu]
    comment = New Share Path
    path = /share/lxu
    browsable = yes
    guest ok = no
    writable = yes
    read only = no
    valid users = root
    create mask = 0755

Restart the smbd
# service smbd restart

Check conf file syntax
# testparm

On the client side
I have a CentOS for my samba client.

Install samba client
# yum install samba-client

Create a mount point
# mkdir /mnt/samba/lxu

Mount samba share from the server
# mount //10.10.10.1/lxu  /mnt/samba/lxu  -o username=root,password=xxxxxxxx

Verify your mount
# mount

To unmount
# umount //10.10.10.1/share

To make the mount permanent
# vi /etc/fstab
Add:
//10.10.10.1/lxu            /mnt/samba/lxu cifs username=root,password=xxxxxxxx 0 0

No comments: