<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alejandro Martínez</title>
    <description>The latest articles on DEV Community by Alejandro Martínez (@alemartinezz).</description>
    <link>https://dev.to/alemartinezz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F748926%2Fc58a150c-04e4-40f6-9b92-1f683d677619.png</url>
      <title>DEV Community: Alejandro Martínez</title>
      <link>https://dev.to/alemartinezz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alemartinezz"/>
    <language>en</language>
    <item>
      <title>Set up Samba client on CentOS/RHEL 7 for file sharing on Windows.</title>
      <dc:creator>Alejandro Martínez</dc:creator>
      <pubDate>Sun, 23 Jan 2022 01:37:28 +0000</pubDate>
      <link>https://dev.to/alemartinezz/set-up-samba-client-on-centosrhel-7-for-file-sharing-on-windows-3a9a</link>
      <guid>https://dev.to/alemartinezz/set-up-samba-client-on-centosrhel-7-for-file-sharing-on-windows-3a9a</guid>
      <description>&lt;p&gt;This article is intended as a general guide. Installing and configuring a SAMBA client on CENTOS 7 for file sharing on Windows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F2258%2F1%2A5YanQ1DHD6UCpvVavS-MyA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F2258%2F1%2A5YanQ1DHD6UCpvVavS-MyA.png" alt="Banner"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1 — Check windows machine Workgroups
&lt;/h2&gt;

&lt;p&gt;Before you proceed to configure samba, make sure the Windows machine is in the same workgroup to be configured on the CentOS server. To check the value in windows machine run the command at cmd prompt:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

net config workstation


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd47yqsc6fnyayvnk1kpb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd47yqsc6fnyayvnk1kpb.png" alt="Workspace visualization"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2 — Install SAMBA
&lt;/h2&gt;

&lt;p&gt;First install Samba4 and required packages from the default CentOS repositories using the:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

dnf &lt;span class="nb"&gt;install &lt;/span&gt;samba&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step 3 — Configure
&lt;/h2&gt;

&lt;p&gt;The main samba configuration file is:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

nano /etc/samba/smb.conf


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;But, before configuring samba, I suggest you to take a backup of the default file like this.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;cp&lt;/span&gt; /etc/samba/smb.conf /etc/samba/smb.conf.orig


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Edit the file according to your needs. In my case I will share the /var/www/html folder and allow the smbgrp group to access it.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faqksjqg6oiecpp7r8xul.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faqksjqg6oiecpp7r8xul.png" alt="Config file 1"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F39gup0f26ryl4pq7hiy3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F39gup0f26ryl4pq7hiy3.png" alt="Config file 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Secure Samba file sharing
&lt;/h3&gt;

&lt;p&gt;As root, create the user you want to access the shared folder. In my case I will be creating a group “smbgrp” allowed to access the shared folder. This allows you to add more users in the future.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

groupadd smbgrp
&lt;span class="c"&gt;# Assign your user to this group.&lt;/span&gt;
usermod user &lt;span class="nt"&gt;-aG&lt;/span&gt; smbgrp
&lt;span class="c"&gt;# Set a password for this user.&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;smbpasswd &lt;span class="nt"&gt;-a&lt;/span&gt; user
&lt;span class="c"&gt;# Also set the appropriate permissions on the directory.&lt;/span&gt;
&lt;span class="nb"&gt;chmod&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; 0775 /var/www/html
&lt;span class="c"&gt;# Assign the full control of the shared folder to the user.&lt;/span&gt;
&lt;span class="nb"&gt;chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; user:smbgrp /var/www/html


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In my case, I will be sharing the html folder in /var/www/html. This is useful for web developers, because lets you edit in realtime a file in the centos server from windows. In a classic Apache HTTP server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Allow Samba server default ports through firewall
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

firewall-cmd --permanent --add-port=137/tcp
firewall-cmd --permanent --add-port=138/tcp
firewall-cmd --permanent --add-port=139/tcp
firewall-cmd --permanent --add-port=445/tcp
firewall-cmd --permanent --add-port=901/tcp
firewall-cmd --reload


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Restart SAMBA services:
&lt;/h3&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

systemctl start smb
systemctl start nmb
systemctl status smb
systemctl status nmb


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step 4 — Verify the shared folder
&lt;/h2&gt;

&lt;p&gt;In order to verify the correct installation, create an example file in the shared folder with touch:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

touch /var/www/html/hola.txt


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In windows, press “Windows Key+R” and submit your ip address, preceded by two inverted slashes: \&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4q36wi7i1bjagtyr88i5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4q36wi7i1bjagtyr88i5.png" alt="Enter to host"&gt;&lt;/a&gt;&lt;br&gt;
You will see your shared folder like this:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3v7i76pbbvm2q9qt3tey.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3v7i76pbbvm2q9qt3tey.png" alt="Shared folder visualization"&gt;&lt;/a&gt;&lt;br&gt;
If you set the user and folder permissions as described before, you should see a login window. In which you must enter your centOS user and the password selected.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fifrql343s3oeg26r2fi8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fifrql343s3oeg26r2fi8.png" alt="Login Step"&gt;&lt;/a&gt;&lt;br&gt;
There is the hola.txt file created from centOS 7.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb8dnnolf8zurtvutqznq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb8dnnolf8zurtvutqznq.png" alt="File created from linux"&gt;&lt;/a&gt;&lt;br&gt;
Finally, start and enable samba services to start automatically at next boot:&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&lt;p&gt;systemctl enable smb.service&lt;br&gt;
systemctl enable nmb.service&lt;br&gt;
systemctl start smb.service&lt;br&gt;
systemctl start nmb.service&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  # Conclusion&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;Setting up Samba is easy, and something to consider if you want easy file sharing between Linux and Windows machines, or even Linux and Linux machines. I gave some context of how to set it up, but there are tons of use cases for Samba. You can also tie it in to different authentication/authorization schemes if you’d like an use it with Active Directory as well. Check out Samba.org for more information.&lt;/p&gt;

</description>
      <category>samba</category>
      <category>centos</category>
      <category>windows</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
