Difference between revisions of "Password Protected Samba Share"

From FOG Project
Jump to: navigation, search
(Created page with "This article describes how to create a basic password protected samba share on Linux. This share can be accessed via Windows, OSX, or Linux. We'll be making a share called <f...")
 
Line 1: Line 1:
 
This article describes how to create a basic password protected samba share on Linux. This share can be accessed via Windows, OSX, or Linux.
 
This article describes how to create a basic password protected samba share on Linux. This share can be accessed via Windows, OSX, or Linux.
  
We'll be making a share called <font color="red">smallshare</font>. It will be accessible via UNC paths in windows as <font color="red">\\x.x.x.x\smallshare</font> where x.x.x.x is the server's IP address. The share will reside on disk at <font color="red">/images/smallshare</font>
+
We'll be making a share called <font color="red">fogshare</font>. It will be accessible via UNC paths in windows as <font color="red">\\x.x.x.x\fogshare</font> where x.x.x.x is the server's IP address. The share will reside on disk at <font color="red">/images/fogshare</font>
  
 
On CentOS 7, Fedora, Ubuntu, and probably Debian, the process is almost identical.
 
On CentOS 7, Fedora, Ubuntu, and probably Debian, the process is almost identical.
Line 32: Line 32:
  
 
Make the directory you want to share:
 
Make the directory you want to share:
<pre>mkdir /images/smallshare</pre>
+
<pre>mkdir /images/fogshare</pre>
  
 
= Create user and set password =
 
= Create user and set password =
Line 52: Line 52:
 
Set permissions on the local directory:
 
Set permissions on the local directory:
  
<pre>chown smalluser:smalluser /images/smallshare
+
<pre>chown smalluser:smalluser /images/fogshare
chmod 770 /images/smallshare</pre>
+
chmod 770 /images/fogshare</pre>
  
 
= Configure Samba =
 
= Configure Samba =
Line 70: Line 70:
 
dos charset = cp932
 
dos charset = cp932
  
[smallshare]
+
[fogshare]
path = /images/smallshare
+
path = /images/fogshare
 
read only = no
 
read only = no
 
create mode = 0777
 
create mode = 0777

Revision as of 05:06, 29 May 2016

This article describes how to create a basic password protected samba share on Linux. This share can be accessed via Windows, OSX, or Linux.

We'll be making a share called fogshare. It will be accessible via UNC paths in windows as \\x.x.x.x\fogshare where x.x.x.x is the server's IP address. The share will reside on disk at /images/fogshare

On CentOS 7, Fedora, Ubuntu, and probably Debian, the process is almost identical.

Install Samba

For CentOS 7 and older, and Fedora 21 and older, install samba:

yum install samba samba-client -y

For Fedora 22 and newer, and probably CentOS 8 and newer, install samba:

dnf install samba samba-client -y

For Ubuntu and Debian, install samba:

apt-get install samba samba-client -y

Start Samba

Start Samba on Fedora/CentOS/RHEL:

systemctl start smb

Start Samba on Ubuntu/Debian:

service smb start

Make the directory

Make the directory you want to share:

mkdir /images/fogshare

Create user and set password

Make a user specifically for it:

useradd smalluser

Set the user's password:

passwd smalluser

Set samba password for the user “small user”, this should match the previous password:

smbpasswd -a smalluser

Set permissions

Set permissions on the local directory:

chown smalluser:smalluser /images/fogshare
chmod 770 /images/fogshare

Configure Samba

Setup the samba configuration script:

vi /etc/samba/smb.conf

Instructions on using Vi: vi

Below is the Samba configuration file. Things above [smallshare] are global and apply to all shares. Then below each bracket name, is settings specific to the share. Feel free to copy/paste.

security = user
passdb backend = tdbsam
unix charset = utf-8
dos charset = cp932

[fogshare]
path = /images/fogshare
read only = no
create mode = 0777
directory mode = 0777
writable = yes
valid users = smalluser

Restart Samba

Then restart Samba in Fedora/CentOS/RHEL:

systemctl restart smb

Restart Samba on Ubuntu/Debian:

service smb restart