If we need to work together with team or access windows storage, we need to mount remote windows share or Samba on CentOS 7.
Mounting Windows or other samba) shares is done through the cifs virtual file system client (cifs vfs) implemented in kernel and a mount helper mount.cifs.
If we are managing a multi user system, consider setting the dir_mode and file_mode options to your mount point.
The default behaviour for mount.cifs is leaving the mounted share unsecured (http://bugs.centos.org/view.php?id=4537).
For Centos:
# yum install samba-client samba-common cifs-utils
For Ubuntu:
# sudo apt-get install cifs-utils samba-common system-config-samba samba winbind
Example output:
[root@pion ~]# yum install samba-client samba-common cifs-utils Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.vodien.com * epel: pkg.adfinis-sygroup.ch * extras: mirror.vodien.com * remi-safe: mirrors.thzhost.com * updates: mirror.vodien.com Resolving Dependencies --> Running transaction check ---> Package cifs-utils.x86_64 0:6.2-10.el7 will be installed --> Processing Dependency: libwbclient.so.0(WBCLIENT_0.9)(64bit) for package: cifs-utils-6.2-10.el7.x86_64 ................................. --> Running transaction check ---> Package libtdb.x86_64 0:1.3.16-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ................................................................. Installed: cifs-utils.x86_64 0:6.2-10.el7 samba-client.x86_64 0:4.9.1-6.el7 samba-common.noarch 0:4.9.1-6.el7 Dependency Installed: libldb.x86_64 0:1.4.2-1.el7 libsmbclient.x86_64 0:4.9.1-6.el7 libtalloc.x86_64 0:2.1.14-1.el7 libtdb.x86_64 0:1.3.16-1.el7 libtevent.x86_64 0:0.9.37-1.el7 libwbclient.x86_64 0:4.9.1-6.el7 samba-client-libs.x86_64 0:4.9.1-6.el7 samba-common-libs.x86_64 0:4.9.1-6.el7 Complete!
Create a local mount point directory, for example:
# mkdir /mnt/windows
Example Windows share detail is:
Remote Windows machine ip address is 192.168.1.9
share name : storage-photo
username: pion
password: my_password
# mount.cifs //192.168.1.9/storage-photo /mnt/windows-storage -o rw,username=pion,password=my_password
If you want to auto mount on boot, edit /etc/fstab and add the following mount command:
\\192.168.63.9\storage-photo /mnt/windows cifs user,uid=1001,rw,suid,username=pion,password=my_password 0 0
The problem from above samba mount configuration is username and password visible to all user.
So we need make it more secure. Put username and password on /root/secret.txt and put your username and password with format:
username=pion
password=my_password
\\192.168.63.9\storage-photo /mnt/windows cifs credentials=/root/secret.txt,rw,_netdev,uid=1001,gid=1001 0 0
We have free backup storage box backup on Hetzner.
This is great feature from Hetzner if you rent Dedicated server with middle or high specs.
This is how we mount storage box using cifs and keep the cradentials on /root directory.