SMB
In this tutorial, i'll use ubntu as my samba client and windows as the smb sahre server
SMB SERVER
This is the list of needed ports to be open by the firewall to let smb do the work properly:
sudo apt install samba
in the /etc/samba/smb.conf add the following lines:
sudo smbpasswd
and provide the user’s password
sudo systemctl restart smbd
Now on my windows machine i should access the shared folder
Samba Client
NOTE: PLEASE READ RED NOTES
In this scenario, i am trying to connect my Ubuntu machine to my Samba share folder (Windows folder )
The Samba protocol (SMB/CIFS) is used for file and printer sharing across a network. It is commonly associated with Windows file sharing, but it is also implemented by Samba, an open-source software that provides SMB/CIFS services on non-Windows platforms like Linux and macOS.
So, the server you are connecting to could be a Windows server, a Linux server running Samba, or any other device that implements the SMB/CIFS protocol.
Install the
cifs-utils
package if it is not already installed:
Create a directory where you want to mount the Samba share. For example:
sudo mkdir /mnt/samba-share
Connect to the shared folder via SMB mount
sudo mount -t cifs -o username=ADMIN,noperm //192.168.1.100/D /mnt/smb_share
noperm: i am telling the linux kernel to ignore permissions, and let samba do the job. If you leave that off you will be connected read only regardless of the share permissions
You will be prompted to enter the password
root@ubuntu:/mnt/smb_share# touch smb_shard.txt
We can perform a persistent mount by editing the /etc/fstab
The kernel needs to read the credentials when booting but we don’t want to store our credentials in plain text, for that we will create a hidden folder
touch .smbcredentials
(You can call it what you want)
vim .smbcredentials
Inside that folder you can pass your username and password:
before I mount, I need to change ownership for the mounting point, because when the system boots up, the user is being used is root
sudo chown touk:touk /mnt/smb_sahre
And now:
vim /etc/fsatb
Inside fstab i use ip address because i don’t know if dns has been loaded or not
Notice that i am not using tild ‘~’, because when at boot time, root is the one being used by kernel
NOTE!!: last 2 options, make sure to use 0. For file system check at boot, if it is set to 1 and your system can not connect to the server, YOUR SYSTEM WILL FAIL TO BOOT!
Last updated