Mount Windows Folder Sharing on RHEL 6/CentOS 6

Scenario:
-Mount Windows Folder Sharing (CIFS) on RHEL 6/CentOS 6.
-Set only Linux user cifs that have RWX access.
-Hide sharing credentials from other Linux users.
-Mount permanent at boot.

System: CentOS 6

Steps:
1) Edit /etc/fstab
# vi /etc/fstab

2) Type mount command in fstab.
Note: By default windows share mounted with the full permission (777) in Linux. To change the default permission use the dir_mode and file_mode options to set directory and file permission.

//WIN_PC_IP/[share name] /[mount point] cifs _netdev,credentials=/root/.filepassw,password>,dir_mode=0755,file_mode=0755,uid=500,gid=500 0 0

in this scenario,only Linux user cifs have read write access on /winshare.

//192.168.99.10/LINUX /winshare cifs _netdev,credentials=/root/.winpasw,dir_mode=0700,file_mode=0700,uid=cifs,gid=cifs 0 0

3) Create folder sharing credential file.
# touch /root/.winpasw

username=srvlinux
password=mypassword
domain=toya.example.com

4) Run mount command to /winshare
# mount -a

Test Result:


login as: cifs
cifs@192.168.99.15's password:
Last login: Sun Oct  31 11:09:45 2017 from 192.168.99.99
[cifs@svrtest ~]$ cd /winshare/
[cifs@svrtest winshare]$ mkdir okttest
[cifs@svrtest winshare]$ ls
oke  okttest  sempak  test
[cifs@svrtest winshare]$ su test
Password:
[test@svrtest winshare]$ ls
ls: cannot open directory .: Permission denied
[test@svrtest winshare]$ cd /
[test@svrtest /]$ cd /winshare/
bash: cd: /winshare/: Permission denied
[test@svrtest /]$

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *