- Running Windows 7 (64 Bit)
- Using VirtualBox 5 to run CentOS 7 as Linux guest
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.
Great guide on running Samba in a CentOS 7 guest on VirtualBox! Fira Code could enhance the coding experience for managing these shares. Thanks for sharing!
ReplyDelete