Difference between revisions of "Guide:Setting up an SMB (Windows) file server"

Jump to navigation Jump to search
whitespace
(whitespace)
Line 8: Line 8:
* Others gloss over or skip file/directory permissions, resulting in "read only" shares and other such frustrations
* Others gloss over or skip file/directory permissions, resulting in "read only" shares and other such frustrations
* Quite a few poor practises (EG: using sudo $EDITOR $FILE, instead of sudoedit). [https://superuser.com/questions/785187/sudoedit-why-use-it-over-sudo-vi Why that is good practise is detailed here.]
* Quite a few poor practises (EG: using sudo $EDITOR $FILE, instead of sudoedit). [https://superuser.com/questions/785187/sudoedit-why-use-it-over-sudo-vi Why that is good practise is detailed here.]


== Prerequisites ==
== Prerequisites ==
Line 20: Line 19:


Suggested: A USB storage device to host the shared directory on (to avoid filling up the System Partition)
Suggested: A USB storage device to host the shared directory on (to avoid filling up the System Partition)
----


This guide will start off from the directory created in a [http://wiki.pine64.org/index.php/Guide-_Adding_USB_storage_to_your_Device_and_Formatting_it_for_linux prior guide]. You dont '''need''' to have the network share hosted on  a USB drive, you can host it anywhere really, I just prefer hosting on this way to avoid filling up the boot partition.  
This guide will start off from the directory created in a [http://wiki.pine64.org/index.php/Guide-_Adding_USB_storage_to_your_Device_and_Formatting_it_for_linux prior guide]. You dont '''need''' to have the network share hosted on  a USB drive, you can host it anywhere really, I just prefer hosting on this way to avoid filling up the boot partition.  


Firstly, you'll need to update your repositories and install any pending updates. This is good practise before installing software on any linux system. [https://www.linux.com/learn/linux-101-updating-your-system Debian/Ubuntu use the "apt" package management tool]. You'll need superuser access for this.  
Firstly, you'll need to update your repositories and install any pending updates. This is good practise before installing software on any linux system. [https://www.linux.com/learn/linux-101-updating-your-system Debian/Ubuntu use the "apt" package management tool]. You'll need superuser access for this.  


<tt>
<tt>
  sudo apt update && sudo apt upgrade </tt>
  sudo apt update && sudo apt upgrade </tt>


Type in your password when prompted and '''y''' when prompted to install updates.  
Type in your password when prompted and '''y''' when prompted to install updates.  


After that, you'll need to invoke '''apt''' to install the samba server:  
After that, you'll need to invoke '''apt''' to install the samba server:  


<tt>
<tt>
  sudo apt install samba samba-common-bin</tt>
  sudo apt install samba samba-common-bin</tt>


[[File:Samba_apt_1.png|800px]]
[[File:Samba_apt_1.png|800px]]


Depending on your distro, '''samba-common-bin''' may already be installed. However, allow the other supporting software to be installed.  
Depending on your distro, '''samba-common-bin''' may already be installed. However, allow the other supporting software to be installed.  
Line 59: Line 44:
<tt>
<tt>
  cd /media/USB-test3/</tt>
  cd /media/USB-test3/</tt>


Make a new directory which will act as the shared location. We will create it with Use/Write/Execute permissions for everybody inside the folder:  
Make a new directory which will act as the shared location. We will create it with Use/Write/Execute permissions for everybody inside the folder:  


<tt>
<tt>
  sudo mkdir -m 1777 RockShare</tt>
  sudo mkdir -m 1777 RockShare</tt>


Now we can edit Samba's configuration file to create a new share based on the directory we just set up:  
Now we can edit Samba's configuration file to create a new share based on the directory we just set up:  


<tt>
<tt>
  sudoedit /etc/samba/smb.conf</tt>
  sudoedit /etc/samba/smb.conf</tt>


[[File:Smb.conf_1.png|800px]]
[[File:Smb.conf_1.png|800px]]


Use the '''Up/Down''' or '''PageUp/Down''' keys to navigate to the bottom of the file to create a new entry.
Use the '''Up/Down''' or '''PageUp/Down''' keys to navigate to the bottom of the file to create a new entry.
Line 94: Line 72:


It should look somewhat similar to this after you've done editing it:  
It should look somewhat similar to this after you've done editing it:  


[[File:Smb.conf_2.png|800px]]
[[File:Smb.conf_2.png|800px]]


These options means that anybody can read, write or execute files in the share, either with a samba user or as a guest. To forbid guest access, simply omit the "guest ok" line. The title, in the square brackets, will be the name of the shared directory.   
These options means that anybody can read, write or execute files in the share, either with a samba user or as a guest. To forbid guest access, simply omit the "guest ok" line. The title, in the square brackets, will be the name of the shared directory.   


Now we can create a specialized user for samba, if you'd like to have your share accessible only with the proper credentials.  
Now we can create a specialized user for samba, if you'd like to have your share accessible only with the proper credentials.  


First of all, you need to make a new linux user. In this case, I will be making a new user "'''rocksmb'''":  
First of all, you need to make a new linux user. In this case, I will be making a new user "'''rocksmb'''":  
Line 110: Line 83:
<tt>
<tt>
  sudo useradd rocksmb</tt>
  sudo useradd rocksmb</tt>


After that, you can create a new samba user, and you'll be prompted to type in a password too. This is a unique password, independent to your linux user password:  
After that, you can create a new samba user, and you'll be prompted to type in a password too. This is a unique password, independent to your linux user password:  


<tt>
<tt>
Line 121: Line 92:
  Added user rocksmb.</tt>
  Added user rocksmb.</tt>
   
   
Now you restart the samba service:  
Now you restart the samba service:  


Line 129: Line 99:
  [ ok ] Restarting smbd (via systemctl): smbd.service.
  [ ok ] Restarting smbd (via systemctl): smbd.service.
  [ ok ] Restarting samba-ad-dc (via systemctl): samba-ad-dc.service.</tt>
  [ ok ] Restarting samba-ad-dc (via systemctl): samba-ad-dc.service.</tt>


Now your Samba share will be visible and accessible!  
Now your Samba share will be visible and accessible!  
Line 135: Line 104:
If you wish to add more users, you simply repeat the steps mentioned above: Create a linux user, then a samba user and password.  
If you wish to add more users, you simply repeat the steps mentioned above: Create a linux user, then a samba user and password.  
You can also experiment with the above samba template, give predefined users different and unique folders if you wish, for example.  
You can also experiment with the above samba template, give predefined users different and unique folders if you wish, for example.  
----


There are many guides about how to access smb shares using '''Windows''':  
There are many guides about how to access smb shares using '''Windows''':  
 
* https://www.howtogeek.com/176471/how-to-share-files-between-windows-and-linux/
 
* http://www.techrepublic.com/article/how-to-connect-to-linux-samba-shares-from-windows-10/
https://www.howtogeek.com/176471/how-to-share-files-between-windows-and-linux/
* https://www.linux.com/news/using-samba-share-files-between-linux-and-windows
 
http://www.techrepublic.com/article/how-to-connect-to-linux-samba-shares-from-windows-10/
 
https://www.linux.com/news/using-samba-share-files-between-linux-and-windows
 


== Mac OS ==
== Mac OS ==
https://support.apple.com/en-au/HT204445
* https://support.apple.com/en-au/HT204445
 


== Ubuntu ==
== Ubuntu ==
https://help.ubuntu.com/stable/ubuntu-help/nautilus-connect.html
* https://help.ubuntu.com/stable/ubuntu-help/nautilus-connect.html
 
 


In all cases, replace the [http://wiki.pine64.org/index.php/Guide-_Setting_up_a_Hostname hostname]/[ http://wiki.pine64.org/index.php/Guide-Locating_your_device IP] in the guide with the ones you have.
In all cases, replace the [http://wiki.pine64.org/index.php/Guide-_Setting_up_a_Hostname hostname]/[ http://wiki.pine64.org/index.php/Guide-Locating_your_device IP] in the guide with the ones you have.
----


If you want to access the drive using mobile apps, there are many apps available on both Android and iOS.  
If you want to access the drive using mobile apps, there are many apps available on both Android and iOS.  


iOS: https://itunes.apple.com/us/app/fileexplorer-file-manager-for-computer-and-nas/id510282524?mt=8
iOS: https://itunes.apple.com/us/app/fileexplorer-file-manager-for-computer-and-nas/id510282524?mt=8


Android: https://play.google.com/store/apps/details?id=com.google.android.sambadocumentsprovider&hl=en
Android: https://play.google.com/store/apps/details?id=com.google.android.sambadocumentsprovider&hl=en


I dont have an iphone, so I'll do a quick rundown using the '''android''' app:  
I dont have an iphone, so I'll do a quick rundown using the '''android''' app:  
Line 192: Line 140:


However Google's app is VERY rudimentary and barebones. I was able to open image files, but video and audio files gave me problems unless I copied them to internal memory.  
However Google's app is VERY rudimentary and barebones. I was able to open image files, but video and audio files gave me problems unless I copied them to internal memory.  


If you need something more full featured, I highly recommend solid explorer:  
If you need something more full featured, I highly recommend solid explorer:  


https://play.google.com/store/apps/details?id=pl.solidexplorer2&hl=en
https://play.google.com/store/apps/details?id=pl.solidexplorer2&hl=en
78

edits

Navigation menu