Configuring Linux Samba (SMB) - How to Setup Samba (Linux Windows File Sharing)
Resource sharing, like file systems and printers, in Microsoft Windows systems, is accomplished using a protocol called the Server Message Block or SMB. For working with such shared resources over a network consisting of Windows systems, an RHEL system must support SMB. The technology used for this is called SAMBA. This provides integration between the Windows and Linux systems. In addition, this is used to provide folder sharing between Linux systems. There are two parts to SAMBA, a Samba Server and a Samba Client.
When an RHEL system accesses resources on a Windows system, it does so using the Samba Client. An RHEL system, by default, has the Samba Client installed.
When an RHEL system serves resources to a Windows system, it uses the package Samba Server or simply Samba. This is not installed by default and has to be exclusively set up.
Installing SAMBA on Linux Redhat/CentOS
Whether Samba is already installed on your RHEL, Fedora or CentOS setup, it can be tested with the following command:"
The result could be - “package samba is not installed,” or something like “samba-3.5.4-68.el6_0.1.x86_64” showing the version of Samba present on the system.
To install Samba, you will need to become root with the following command (give the root password, when prompted):
Then use Yum to install the Linux Samba package:
This will install the samba package and its dependency package, samba-common.
Before you begin to use or configure Samba, the Linux Firewall (iptables) has to be configured to allow Samba traffic. From the command-line, this is achieved with the use of the following command:
Configuring Linux SAMBA
The Samba configuration is meant to join an RHEL, Fedora or CentOS system to a Windows Workgroup and setting up a directory on the RHEL system, to act as a shared resource that can be accessed by authenticated Windows users.
To start with, you must gain root privileges with (give the root password, when prompted):
Edit the Samba configuration file:
The smb.conf [Global] Section
An smb.conf file is divided into several sections. the [global] section, which is the first section, has settings that apply to the entire Samba configuration. However, settings in the other sections in the configuration file may override the global settings.
To begin with, set the workgroup, which by default is set as “MYGROUP”:
Since most Windows networks are named WORKGROUP by default, the settings have to be changed as:
Configure the Shared Resource
In the next step, a shared resource that will be accessible from the other systems on the Windows network has to be configured. This section has to be given a name by which it will be referred to when shared. For our example, let’s assume you would like share a directory on your Linux system located at /data/network-applications. You’ll need to entitle the entire section as [NetApps] as shown below in our smb.conf file:
[NetApps]
path = /data/network-applications
writeable = yes
browseable = yes
valid users = administrator
“NetApps”.
This concludes the changes to the Samba configuration file.
Create a Samba User
Any user wanting to access any Samba shared resource must be configured as a Samba User and assigned a password. This is achieved using the smbpasswd command as a root user. Since you have defined “administrator” as the user who is entitled to access the “/data/network-applications” directory of the RHEL system, you have to add “administrator” as a Samba user.
You must gain root privileges with the following command (give the root password, when prompted):
Add “administrator” as a Windows user -
The system will respond with
Retype new SMB password: <Retype password>
This will result into the following message:
It will also be necessary to add the same account as a simple linux user, using the same password we used for the samba user:
# passwd administrator
Changing password for user administrator
New UNIX password: ********
Retype new UNIX password: ********
passwd: all authentication tokens updated successfully.
Rlimit_max: rlimit_max (1024) below minimum Windows limit (16384)
Processing section “[NetApps]”
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
If you would like to ensure that Windows users are automatically authenticated to your Samba share, without prompting for a username/password, all that’s needed is to add the samba user and password exactly as you Windows clients usernames and password. When a Windows system accesses a Samba share, it will automatically try to log in using the same credentials as the user logged into the Windows system.
Starting Samba and NetBios Name Service on RHEL
The Samba and NetBios Nameservice or NMB services have to be enabled and then started for them to take effect:
In case the services were already running, you may have to restart them again:
# systemctl restart nmb.service
If you are not using systemctl command, you can alternatively start the Samba using a more classic way:
Starting SMB services: [OK]
To configure your Linux system to automatically start the Samba service upon boot up, the above command will need to be inserted in the /etc/rc.local file. For more information about this, you can read our popular Linux Init Process & Different run levels article
Accessing the Samba Shares From Windows
Now that you have configured the Samba resources and the services are running, they can be tested for sharing from a Windows system. For this, open the Windows Explorer and navigate to the Network page. Windows should show the RHEL system. If you double-click on the RHEL icon, you will be prompted for the username and password. The username to be entered now is “administrator” with the password that was assigned.
Again, if you are logged on your Windows workstation using the same account and password as that of the Samba service (e.g Administrator), you will not be prompted for any authentication as the Windows operating system will automatically authenticate to the RHEL Samba service using these credentials.
Accessing Windows Shares From RHEL Workstation or Server
To access Windows shares from your RHEL system, the package samba-client may have to be installed, unless it is installed by default. For this you must gain root privileges with (give the root password, when prompted):
Install samba-client using the following commands:
To see any shared resource on the Windows system and to access it, you can go to Places > Network. Clicking on the Windows Network icon will open up the list of workgroups available for access.
Your IP address:
18.217.208.220
Wi-Fi Key Generator
Follow Firewall.cx
Cisco Password Crack
Decrypt Cisco Type-7 Passwords on the fly!