File Server With Samba

After installing and running the server, it’s time to create the users and edit the configuration file (and then restart the server).

The Samba users must be also local users on the server machine.

But what users do we need to create? We need to add any user on the client computers that means to connect to the File Server.

For example, let’s imagine the user ‘daniele’ on a Linux machine is going to use the File Server. On the server, we need to create the local user ‘daniele’ (adduser daniele) and the Samba user ‘daniele’ (smbpasswd -a daniele).

Now, let’s imagine the user ‘pippo’ on a Windows machine is going to user the File Server. On the server, we need to create the local user ‘pippo’ and the Samba user.

All Samba users are in:
/etc/samba/smbpasswd

///////////////////////////////////////////////////////////////////////////

The configuration file will be like this:

[global]
workgroup = Home
encrypt passwords = yes
os level = 255
preferred master = Yes
domain master = Yes
dns proxy = No

[Public]
comment = Public files
path = /home/samba_public
read only = no
browseable = yes
valid users = daniele, pippo
inherit permissions = Yes

[Daniele]
comment = Daniele’s files
path = home/daniele
valid users = daniele
read only = No

[Pippo]
comment = Pippo’s files
path = home/pippovalid users = pippo
read only = No

Some important notes:

  • workgroup must be the same workgroup of the Windows computers that will connect to the server (anyway, it’s easy to change the workgroup in the Windows)
  • In the global section, don’t use anything like this:
    netbios name = Home File Server
    I have found it on a few howtos, but, if you use it, there will be trouble when you’ll try to access the File Server from the Windows.

//////////////////////////////////////////////////////////////////////////////////////////

To access the File Server from Linux, you could use either:

  • Konqueror – on the address bar you’ll type:
    smb://192.168.1.7/Daniele
  • the command line:
  • smbclient -U username //192.168.1.7/Daniele

    You don’t need to specify the username if the username you’re using locally is the same you want to use remotely.

    At this point, you’ll have a ftp-like client.

To access the File Server from Windows, you have to click on Network Resources from the Start Menu and then on Find other computers in the same Workgroup (or something like that).

Make sure Samba port is open on the server.

//////////////////////////////////////////////////////////////////////////////////////////

Troubleshooting

If you get this error:

tree connect failed: NT_STATUS_BAD_NETWORK_NAME

it’s probably because CentOS (and most of the similar distros) blocks home shares in Samba by default through SELinux policies, that is set to Enforced.

To fix you can set SELinux policies to permissive (through the command system-config-securitylevel) o, in order to keep an high level of strictnes, you could go to the /etc/selinux/targeted directory, create a text file called booleans.local, and put the “samba_enable_home_dirs=1″ line in it (without the quotes, of course).

This entry was posted in LAN, Redhat / CentOS. Bookmark the permalink.

Leave a Reply