How to mount Windows shares or Samba on Linux Centos and Ubuntu

The default behaviour for mount.cifs is leaving the mounted share unsecured

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

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,user=pion,pass=my_password,dom=domain.local,vers=3.0

If you want to auto mount on boot, edit /etc/fstab and add the following mount command:

//192.168.1.9/storage-photo /mnt/windows-storage cifs rw,user=pion,pass=my_password,dom=domain.local,vers=3.0

show map

df -h

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.

Leave a Reply

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

RELATED POST

How to automatically restart Linux services with Systemd

Getting your Linux deployments working reliably is of paramount concern for production applications. One way to guarantee that a service…

How to Install SFTPGo on Ubuntu 22.04

Setup UFW Firewall For security reasons, it is recommended to install and configure the UFW firewall in your system. First,…

Executing Bash Scripts at Startup in Ubuntu Linux

Creating a Bash script in Ubuntu To create a Bash script in Ubuntu, you can use any text editor of…

How To Clear PHP’s Opcache

PHP can be configured to store precompiled bytecode in shared memory, called Opcache. It prevents the loading and parsing of PHP…