Centos – configuring Samba to access via Windows network

You may need to access the files in your virtual machine from time to time while developing. It sucks how you need to run your FTP client or even use SFTP just to put that missing semicolon in your PHP script. In this article, we will show you how to access your virtual machines files and directories via the Windows network.

We will assume that your virtual machine is a CentOS and has a user named ‘myuser’.

First you need to install Samba. Basically, it allows machines to access each others files through a network. You can install it in various ways but since we are using Centos, we will use the yum package manager.

yum install samba

Now, you need to configure your samba service. There are a lot of tweaks that may work, but here is my current configuration.

[global]
workgroup = WORKGROUP
map to guest = bad user
security = user
passdb backend = tdbsam

[myuser]
path = /home/myuser
writable = yes
browseable = yes
valid users = myuser

The workgroup configuration must be the same as your networks workgroup. Mostly it is WORKGROUP so there is not much to worry.

Now Add your user (myuser) to samba. It will ask you a password. Once you do this your user can now access the shared directories as long as it is in the valid users configuration

smbpasswd -a myuser

Lastly, add smb and nmb daemons on boot.

chkconfig smb on
chkconfig nmb on

If you have SELinux enabled you need to enable the following SELinux booleans.

setsebool samba_domain_controller on
setsebool samba_enable_home_dirs on

Remember to restart the services to apply your changes and refresh your network directory in Windows. If it does not work, let’s have a chat down the comments 😀

Below are some references to samba’s documentation about its config file

Chapter 6. The Samba Configuration File
smb.conf — The configuration file for the Samba suite

0 thoughts on “Centos – configuring Samba to access via Windows network”

Leave a Reply

%d bloggers like this: