Running Samba Inside CentOS 7
Running Samba Inside CentOS 7
A tutorial for running Samba inside the CentOS guest to access folders in the running CentOS guest from a Windows 7 host system.
Join the DZone community and get the full member experience.Join For Free
Download the blueprint that can take a company of any maturity level all the way up to enterprise-scale continuous delivery using a combination of Automic Release Automation, Automic’s 20+ years of business automation experience, and the proven tools and practices the company is already leveraging.
This was a problem puzzling me a complete day. My environment is as follows:
- Running Windows 7 (64 Bit)
- Using VirtualBox 5 to run CentOS 7 as Linux guest
I was looking for a solution to create a Samba share inside the CentOS guest, so I am able to access folders in the running CentOS guest from my Windows 7 host system.
I configured VirtualBox to use two network adapters (NAT and Host-Only).
I installed Samba on the CentOS guest and configured it as a Standalone Server. I created a Samba share called "data". See the full smb.conf here, the Samba share is defined at the end of the file:
[global] workgroup = WORKGROUP server string = Samba Server Version %v dns proxy = no # log files split per-machine: log file = /var/log/samba/log.%m # maximum size of 50KB per log file, then rotate: max log size = 50 security = user passdb backend = tdbsam load printers = yes cups options = raw server role = standalone server encrypt passwords = true guest ok = yes usershare allow guests = yes obey pam restrictions = yes unix password sync = yes passwd program = /usr/bin/passwd %u passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . pam password change = yes map to guest = bad user #============================ Share Definitions ============================== [homes] comment = Home Directories browseable = no writable = yes ; valid users = %S ; valid users = MYDOMAIN\%S [printers] comment = All Printers path = /var/spool/samba browseable = no guest ok = no writable = no printable = yes [data] comment = Data Folder path = /data guest ok = yes browseable = yes create mask = 0777 directory mask = 0777 writable = yes force create mode = 777 force directory mode = 777 force security mode = 777 force directory security mode = 777
This Samba configuration works in an Ubuntu 14.04. VirtualBox guest OS perfectly. But no matter what I did, this configuration did not work in CentOS. I always got a "Permission denied" error when I tried to access the Samba share from the Windows host using \\centos-guest\data\
Well it turned out, that the problem was a running firewall AND SELinux (Security-Enhanced Linux). To disable both do the following steps in CentOS:
- systemctl stop firewalld
- systemctl disalbe firewalld
- vi /etc/selinux/config
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # change # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
After this, reboot the guest OS and you can access the samba shares of your CentOS guest on your Windows host.
But be warned, you disabled the firewall on your Linux guest OS!
If this is not what you want, you should find an alternative approach.
Published at DZone with permission of Ralf Quebbemann , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.