Sunday, December 8, 2013

6:30 AM
Simple File Sharing in Mint

Notes: 

** This HowTo pertains to the Gnome / Cinnamon versions of Mint but there is a way to create shares from Thunar in the XFCE version - with a little bit of work:

** There is no implementation of a Samba Usershare in MATE. There is something similar but you will need to manually change permissions to make it work.


There are two different ways to create Samba shares in Mint Gnome:
Nautilus-shares ( also known as User Shares, or Simple shares )
Classic-shares

This HowTo is about Nautilus-share as it has become the default method to create shares on Mint and Ubuntu. Nautilus-share definitions are located in /var/lib/samba/usershares as opposed to /etc/samba/smb.conf in "Classic Samba".

This method is invoked by Opening Nautilus ( or Nemo ) > right clicking on the directory you want to share > Sharing Options. Please
note that you can only share folders that you own ( i.e., folders in your own home directory or mount points to partitions where you are the owner, for example ) although there are ways around this limitation. 

This method relies on the following package:
nautilus-share ( this should be part of the base install )
nemo-share ( on Mint Cinnamon )

Linux Mint Debian Edition Preliminary Steps
There are a few steps required first if you're using the Mint Debian Edition. Please see a detailed description below:
viewtopic.php?f=42&t=23169&p=315218#p315218

(1) Create a Shared Directory

Open Nautilus ( Menu > Home Folder ) or Nemo ( Menu > Files ) as a regular user ( you can only share folders you own )
Right click on the directory you wish to share
Select "Sharing Options"
Select "Share this Folder"

Now you have some decisions to make. 

(1a) If you want your users ( or guests ) to have write access then:
Select "Allow other people to write in this folder"

(1b) If you want everyone in your home network to have access to that shared folder:
Select "Guest Access"

(1c) When you click on Create Share a dialog box pops up and asks you if you want Nautilus to add permissions automatically - you do.

NOTE 1: If you allow "guest access" you're done. You can skip the rest of 
this document ( except for the bug fix mentioned below ). Everyone on the
network will be able to Read and/or Write from/to that folder. If you don't
want guest access then you will have to create users with passwords
( explained later )

NOTE 2: If you allow guest access and you are connected directly to the internet
everyone will have access. If you have a home network and are behind a Router
you should be OK since the outside world can't see your individual machine

(1d) If you want username and password authentication before anyone accesses your share then proceed to step (2) 

(2) Accessing Shares with Authentication
I will show 2 of the more common scenarios of how that can be done and use the following keys:

ShareOwnerUserName = The actual login name on the machine whose folders you want to share on the network.
RemoteUserName = The actual login name of a remote user who wants access to that share.

File sharing in linux with authentication requires two completely different sets of usernames and passwords.

[] Scenario 1: Accessing the share using the Share Owner's User Name.
Even though the Share Owner already has a login name and password it must also have a "Samba" user name and password:

On the Mint Box with the share:
Open Terminal
Type sudo smbpasswd -a ShareOwnerUserName
Replace "ShareOwnerUserName" with the actual login name of the owner of the share
Type Some_User_Password (when prompted)
Replace "Some_User_Password" with an actual password. This does not have to match Share Owner's login password - in fact for security / privacy reasons you may not want them to match. But it will be the password that is used to access the share.
When completed the terminal should output: "Added user ShareOwnerUserName"

[] Scenario 2: Accessing the share using the Remote User's Name 
This is more complicated since you can't create a samba user without creating a new user on the box with the share.

Create a Remote User Name account on the Mint Box with the share:

On the Mint Box with the share:
Menu > Administration > Users and Groups > Unlock > Add User > 
Username: RemoteUserName
Replace "RemoteUserName" with the actual name that the remote user uses to log into his own machine. 
Password: Can be anything.
Does not have to match the password that the Remote User uses to login into his own machine. In fact for security / privacy reasons you may not want them to match. Please note that you don't even have to disclose this password to the remote user as this will not be the password he uses to access your share.

NOTE: There is another way to add a new user to the Mint Box with the share if the only reason you're adding it is for share access:
Open Terminal
Type sudo useradd -s /bin/true RemoteUserName
This will create a linux user on the server that has no server logon capability and no server home directory.

Create a Remote User Name Samba account:

On the Mint Box with the share:
Open Terminal
Type sudo smbpasswd -a RemoteUserName 
Replace "RemoteUserName" with the one you created above.
Type Some_User_Password (when prompted)
Can be anything. Does not have to match RemoteUserName's login password above. This will be the password the Remote User uses to access the share.
When completed the terminal should output: "Added user RemoteUserName"

When you use Windows' My Network Places you should be able to see the shares of your linux box and depending on whether you require a username and password you would input the Samba Users name and password. 

There is little documentation on the web on "how" natilus-share works only howtos on its use and most of that is outdated or incorrect. The following are some observations I have discovered by trial and error:

(1) "Guest Access" will not be available unless the line:
usershare allow guests = yes is somewhere in etc/samba/smb.conf. It's included in the default smb.conf as part of the install but if you have written your own it may not be there so you will have to add it back.

NoteOn Mint Debian that line is not present in smb.conf by default so it will have to be added and samba ( note in Debian it's samba not smbd ) will have to be restarted:

CODE: SELECT ALL
sudo service samba restart


(2) There is a bug in the nautilus-share package as of this writing that does not change the username and groupname to your name and group for any file that a remote user adds to your share. This makes it impossible for you to write to that file. Here is a workaround: add the following line to the [global]section of etc/samba/smb.conf :
force user = whatever_your_mint_user_name_is

(3) In classic samba you can add parameters such as "hosts allow" and "hosts deny" to the "share" portion of smb.conf. There is no "share portion" in smb.conf using usershares. You can still use these parameters in smb.conf and they will control access but only globally for all shares.

(4) The biggest difference between usershares and classic samba is the contol of Samba User access. In usershares all Samba Users will have access to all shared directories that require authentication. In classic shares you can dictate exactly what user has access to what share.

0 comments :

Post a Comment