Using Samba on CentOS With Windows 7/8

·

,

Go ahead and install the samba packages:

sudo yum install samba samba-client samba-common
smbd --version
sudo chkconfig smb on
sudo chkconfig nmb on
sudo nano /etc/selinux/config

Disable SELINUX by editing /etc/selinux/config and make one small change:

SELINUX=disabled

Make some additions to iptables:

sudo iptables -I INPUT 4 -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
sudo iptables -I INPUT 5 -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
sudo iptables -I INPUT 6 -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
sudo service iptables save

NOW, restart the server:

sudo reboot now

Backup and modify smb.conf:

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
sudo rm /etc/samba/smb.conf
sudo touch /etc/samba/smb.conf
sudo nano /etc/samba/smb.conf

The file should contain:

[global]
workgroup = WORKGROUP
server string = server_name
security = user
map to guest = bad user

[private-share]
path = /media/sdd
valid users = @smbgrp
guest ok = no
writable = yes
browsable = yes

Restart smb and nmb:

sudo service smb restart
sudo service nmb restart

Add your groups and add users to them:

sudo groupadd smbgrp
cd /media/sdb
sudo mkdir secureshare
sudo chown -R username:smbgrp secureshare/
ls -l
sudo chmod -R 0770 secureshare/
sudo usermod -a -G smbgrp username
sudo smbpasswd -a username
sudo service smb restart
sudo service nmb restart
sudo testparm

private-share

Now connect from a windows PC using credentials from CentOS server by right-clicking within “Computer” and selecting “Add a network location”. Follow the prompts and your share will be usable from Windows!

If you cannot connect, it’s most likely the firewall on the CentOS machine. Backup and then flush iptables to test if needed, and then rebuild your firewall accordingly. If you cannot get access to your shares, you have a permissions problem on the server end. Check users, groups, share permissions, and smb.conf for proper values.

You’re welcome 😉

2 responses to “Using Samba on CentOS With Windows 7/8”

  1. Never is too late to say… THANKS! I needed a fast way to do it!

  2. Never is too late to say… THANKS! I needed a fast way to do it!

Leave a Reply

Discover more from Rich Collier

Subscribe now to keep reading and get access to the full archive.

Continue reading