Install Samba (Windows Share) on CENTOS 7
It is important for web developers to access the web files on a development server. However, if dev team requires to access it via windows share over CENTOS machine, then we need to install Samba.
Here's my quick list of installing Samba on CENTOS.
1.) Check for existing samba package if any using the following commands
#rpm -qa | grep samba
#yum list installed | grep samba
2.) If samba is installed, remove it using the below command
#yum remove samba*
3.) For SMB new User. Create a user and add to a group
#useradd -s /sbin/nologin [username]
#groupadd [smbgroupname]
Note: To know more about managing user and group just click here
4.) Now, install samba using the following command
#yum install samba* -y
5.) Assign the user username to [smbgroupname], and set samba password to that user
#usermod -a -G [smbgroupname] [username]
#smbpasswd -a [username]
6.) Create a new share called “/samba/secure_share” and set the permissions to that share
#mkdir /samba/secure_share
#chmod -R 0755 /samba/secure_share
#chown -R [username]:[smbgroupname] /samba/secure_share
7.) Edit samba config file;
#vi /etc/samba/smb.conf
8.) Add the below lines at the bottom of samba config file.
[secure_share]
path = /samba/secure_share
writable = yes
browsable = yes
guest ok = no
valid users = @[smbgroupname]
9.) Test the samba configuration for any errors.
#testparm
10.) To start Samba service on system boot
#systemctl start smb
#systemctl start nmb
#systemctl enable smb
#systemctl enable nmb
11.) Firewall configuration. Allow Samba server default ports through firewall.
#firewall-cmd --permanent --zone=public --add-port=137/tcp
#firewall-cmd --permanent --zone=public --add-port=138/tcp
#firewall-cmd --permanent --zone=public --add-port=139/tcp
#firewall-cmd --permanent --zone=public --add-port=445/tcp
#firewall-cmd --permanent --zone=public --add-port=901/tcp
#firewall-cmd --permanent --add-port=137/tcp
#firewall-cmd --permanent --add-port=138/tcp
#firewall-cmd --permanent --add-port=139/tcp
#firewall-cmd --permanent --add-port=445/tcp
#firewall-cmd --permanent --add-port=901/tcp
#firewall-cmd --list-ports
12.) Restart firewall to apply the changes.
#firewall-cmd --reload
13.) SELinux Configuration ( Skip this part if you already disabled SELinux)
Turn the samba_enable_home_dirs Boolean on if you want to share home directories via Samba.
setsebool -P samba_enable_home_dirs on
Label the /samba/secure_share/ with samba_share_t so that SELinux allows Samba to read and write to it.
#chcon -t samba_share_t /samba/secure_share/
#systemctl restart smb
#systemctl restart nmb
14.) To disable SELinux, edit file /etc/sysconfig/selinux,
#vi /etc/sysconfig/selinux
15.) Set SELinux value to disabled.
#SELINUX=disabled
16.) Finally, browse the shared folder you have configured.
References:
https://www.unixmen.com/install-configure-samba-server-centos-7/
Labels:
CENTOS,
File Sharing,
Server
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment