How To - Simple File Sharing in Mint

Write tutorials and howtos in here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Do not start a support topic here please. Before you post please read this

How To - Simple File Sharing in Mint

Postby altair4 on Fri Mar 13, 2009 9:11 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: Create Samba Shares Directly from Thunar: viewtopic.php?f=197&t=88255

** 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.

Note: On 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.
Last edited by altair4 on Thu Feb 14, 2013 1:04 pm, edited 34 times in total.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5802
Joined: Tue Feb 03, 2009 10:27 am

Linux Mint is funded by ads and donations.
 

Re: Simple File Sharing in Mint 6

Postby Husse on Sun Mar 15, 2009 10:45 am

You've been busy
This is the second post from you I discover today that should be sticky
I think I'll use this one because it seems to be what I do myself when I try to fix my shaky home network :) and it's put more concise than I can put it :)
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19710
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: Simple File Sharing in Mint 6

Postby altair4 on Sat Apr 04, 2009 1:34 pm

This came up in another post so I thought I'd add an addendum to this topic.

Let's say your user name is "chuck". If you try to share /home/chuck you'll get an error message that looks like this:
'net usershare' returned error 255: net usershare add: share name chuck is already a valid system user name

You cannot have a share name match a user name so the workaround for this is to change the share name to "chucks" or"chuck_share" or anything other than "chuck".

The other thing to keep in mind is that you might inadvertently create a share name that matches a username you were not aware existed. If you look at the contents of /etc/passwd it will show you the list of users on your system. All of them except the ones you created are internal system names and as such are subject to the same rule. So don't call one of your shares "backup" for example.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5802
Joined: Tue Feb 03, 2009 10:27 am

Re: Simple File Sharing in Mint

Postby richardG891 on Sat Jun 13, 2009 1:22 pm

Sharing from External Drives
I've got file sharing enabled by setting up a samba username and password, and right-clicking on the folder I want to share in nautilus.... etc.... all fine. BUT, when I share a folder on an USB external drive (part (4)), the share is "forgotten" when I reboot, or unmount/remount the drive. Is there an EASY way to make the share persistent. I can probably edit smb.conf if it's spelled out. Thanks in advance.
richardG891
Level 1
Level 1
 
Posts: 15
Joined: Sat Jun 13, 2009 1:05 pm

Re: Simple File Sharing in Mint

Postby altair4 on Sat Jun 13, 2009 3:55 pm

Every time I've shared an external usb drive it was "on the fly". Enough to transfer whatever I needed and then "un-shared" and unmounted. There are probably many reasons not to do this, and I'm not in the habit of doing it myself but you could mount the device in fstab. Something like this:

(1) Create a mount point in your home directory.

Open Terminal
Type mkdir /home/your_user_name/Seagate ( Seagate is the name of my external HDD )

(2) Add a line to /etc/fstab

Open Terminal
Type sudo blkid

You should get something like this: /dev/sdc1: LABEL="SEAGATE" UUID="435A-3337" TYPE="vfat"

Then the line you would add in /etc/fstab would be:
UUID=435A-3337 /home/your_user_name/Seagate vfat user,noauto,exec,utf8 0 0

(3) Share your /home/your_user_id/Seagate folder

I'll have to investigate this behaviour when I get my Seagate Drive back. I don't know why it wouldn't persist between reboots when it's mounted normally in /media.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5802
Joined: Tue Feb 03, 2009 10:27 am

Re: Simple File Sharing in Mint

Postby altair4 on Sat Jun 13, 2009 6:09 pm

Before you go through the trouble of doing what I wrote above, I just remembered that my wife brought home her seagate drive from work so I did an experiment. I think you may have found a bug in how nautilus reports the share. Here is what I did:

I turned on the Seagate drive and allowed it to mount in /media the way a default Mint install should mount it. Then I shared it which created this entry into /var/lib/samba/usershare:
#VERSION 2
path=/media/SEAGATE
comment=
usershare_acl=S-1-1-0:R
guest_ok=y

I could access the share from the WinXP box on my LAN.

Then I rebooted both boxes and turned on the Seagate. When I went to nautilus and selected /media/SEAGATE > Properties > Share it indicated that the drive was not shared yet I could access the contents from the WinXP box and of course the /var/lib/samba/usershare above was still there. I think this is just a bug in nautilus and not the actual state of the "share". The only definitive list of what shares you have are in /var/lib/samba/usershare. What's more bizarre is that it will eventually show that it's shared in the properties tab. What triggers that I do not know.

When you say that the share was "forgotten" are you describing what happened above - Nautilus says it's not shared. Or did you try to access it from another box and it is in fact not shared ?
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5802
Joined: Tue Feb 03, 2009 10:27 am

Re: Simple File Sharing in Mint [SOLVED}

Postby richardG891 on Mon Jun 15, 2009 2:42 am

Just checked... yes, I can see and access the shares on both my XP machine (that had connected to the share previously) and my ubuntu laptop that I've just plugged in. And nautilus (on the Mint PC host) is currently telling me the drive isn't being shared. Thanks very much, you're absolutely right, it's a bug in Nautilus.
richardG891
Level 1
Level 1
 
Posts: 15
Joined: Sat Jun 13, 2009 1:05 pm

Re: Simple File Sharing in Mint

Postby altair4 on Thu Jun 18, 2009 8:12 am

Please note that there a series of 3 bugs in the way nautilus "reports" the state of the share using this method. It does not impact the actual share status, they are only bugs in the way nautilus displays the state of the share:

[1] Emblem Status.
When you first create the share, nautilus changes the folder icon from this:
Share_Icon.png
Share_Icon.png (2.45 KiB) Viewed 66274 times

to this:
Share_Icon_Shared.png
Share_Icon_Shared.png (3.03 KiB) Viewed 66281 times

When you reboot or login again it reverts to the original "unshared" emblem.
There is a workaround for this if it really bothers you. This bug only affects shares made to the base directories - Documents, Pictures, Videos, Music etc.. but if you create your own directories say MyDocuemnts, MyPictures,... the emblem survives the reboot.

[2] Write Option Display Status
After you create the share with "write" enabled subsequent inspection of the Properties > Share Tabs will indicate that it has been disabled. It really isn't disabled it's just a display bug.

[3] Properties > Share > all options are blank bug
This is the bug that richardG891 reported above. The problem with this one is I've only been able to reproduce this bug once. The folks over at Ubuntu can't reproduce it all so unless we can figure out a repeatable and reliable way to induce this bug I don't think it will get fixed.

Item [1] is being worked on by the Ubuntu team. Item [2] has actually been fixed but resides in the unstable repos so it may or may not end up in mintUpdate for this current release. You may have to wait for the next release.

You can follow the status of the bugs here:
https://bugs.launchpad.net/ubuntu/+sour ... bug/280480
And here:
viewtopic.php?f=166&t=27667
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5802
Joined: Tue Feb 03, 2009 10:27 am

Re: Simple File Sharing in Mint

Postby lvleph on Thu Aug 13, 2009 1:26 pm

I am trying to share an ntfs partition with a virtual machine. When I try to share using my user it says it cannot change permissions. So then I decided to use gksu nautilus. It allows the share to be setup. I am setting it up for guests, but when I try to access the share from any computer it will not allow access. I am using the original smb.conf, so it does have usershare allow guests = yes.
lvleph
 

Re: Simple File Sharing in Mint

Postby altair4 on Thu Aug 13, 2009 2:48 pm

I'm confused. If you're trying to share an ntfs partition on the host to the VBox Guest then you don't need to use any kind of samba to share it to the guest. Make sure you've installed Guest Additions on the guest and then in VBox go to Settings > Shared Folders > Add New Shared Folder.

I am setting it up for guests, but when I try to access the share from any computer it will not allow access. I am using the original smb.conf, so it does have usershare allow guests = yes.

If you're trying to access the share from a non-VBox computer: What is the error message you are getting and how you are mounting the ntfs partition. If you are automounting at boot I need to see the entry in /etc/fstab that defines how it's mounted.

EDIT:
Also please post the output of the following command: sudo net usershare info
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5802
Joined: Tue Feb 03, 2009 10:27 am

Re: Simple File Sharing in Mint

Postby lvleph on Thu Aug 13, 2009 3:18 pm

altair4 wrote:I'm confused. If you're trying to share an ntfs partition on the host to the VBox Guest then you don't need to use any kind of samba to share it to the guest. Make sure you've installed Guest Additions on the guest and then in VBox go to Settings > Shared Folders > Add New Shared Folder.

I am setting it up for guests, but when I try to access the share from any computer it will not allow access. I am using the original smb.conf, so it does have usershare allow guests = yes.

If you're trying to access the share from a non-VBox computer: What is the error message you are getting and how you are mounting the ntfs partition. If you are automounting at boot I need to see the entry in /etc/fstab that defines how it's mounted.

EDIT:
Also please post the output of the following command: sudo net usershare info

Well, I was also trying to get other computers to access it, but my main purpose was VBox. Anyway, my wife's Mint computer says "Unable to mount location: file doesn't exist."

udo net usershare info
Code: Select all
path=/media/Media
comment=Media Drive on Erich's
usershare_acl=Everyone:F,
guest_ok=y


/etc/fstab entry
Code: Select all
# /media/Media was on /dev/sda3 during installation
UUID=284F243607E75E6A /media/Media    ntfs    defaults,nls=utf8,umask=007,gid=46 0       1


EDIT: Also, guest editions has never allowed me to access a share. Not sure why, but I found that using samba was an easy workaround, until mint.
lvleph
 

Re: Simple File Sharing in Mint

Postby altair4 on Thu Aug 13, 2009 3:42 pm

I think I see the problem. Samba permissions governs if you may access a share, the individual directory / file permissions governs if you can access a share. Usershare can "correct" this for an ext3 filesystem but it can't for a Fat32 or NTFS filesystem.

Press Alt+F2
Type gksu gedit /etc/fstab
Now Change that line in fstab from this:
UUID=284F243607E75E6A /media/Media ntfs defaults,nls=utf8,umask=007,gid=46 0 1
To this:
UUID=284F243607E75E6A /media/Media ntfs defaults,nls=utf8,umask=000,gid=46 0 1

Reboot

That last "7" forbids any guest from accessing the directory - a "0" allows guests to have access.
Give it a shot. :wink:
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5802
Joined: Tue Feb 03, 2009 10:27 am

Re: Simple File Sharing in Mint

Postby lvleph on Thu Aug 13, 2009 3:52 pm

That just solved a bunch of problems I was having with NTFS that I didn't realize were all related. Thanks.
lvleph
 

Re: Simple File Sharing in Mint

Postby altair4 on Thu Aug 13, 2009 3:57 pm

You're very welcome.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5802
Joined: Tue Feb 03, 2009 10:27 am

Re: Simple File Sharing in Mint

Postby SallyK on Sat Oct 17, 2009 5:32 pm

In many years of (intermittent) trying, we've never managed to get any of our Windows computers to talk to each other.

Following your incredibly useful guide, it took all of 10 mins to be able to play a video file off one computer on to the other, and to copy a file back again. Another score for Linux.

The only problem I have is that the file I've copied has lost its permissions in transit, so I can't write to it.

I tried adding the force user = whatever_your_mint_user_name_is line to etc/samba/smb.conf but it doesn't seem to have made any difference. At the moment, it's at the end of file - is there somewhere specific that it needs to go?

One thing I did notice is that step (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." didn't seem to happen, it just created the share. I don't know if that's relevant at all?

The computer I copied the file from is running Ubuntu under Wubi, if that makes any difference at all.

Anyway, as it is, this is still incredibly useful - thank you very much for such clear and well laid out instructions.
User avatar
SallyK
Level 3
Level 3
 
Posts: 177
Joined: Fri Oct 02, 2009 5:22 pm

Re: Simple File Sharing in Mint

Postby altair4 on Sat Oct 17, 2009 7:34 pm

Bless you for the kind words.
I tried adding the force user = whatever_your_mint_user_name_is line to etc/samba/smb.conf but it doesn't seem to have made any difference. At the moment, it's at the end of file - is there somewhere specific that it needs to go?

You know I've looked and reworked my Howto for months and never realized that I never stated where to put that line. It actually can make a difference depending on how your smb.conf file is set up. I would like you to post your smb.conf by doing this:

Open Terminal
Type testparm -s
Just copy and paste the output in your reply.

While you're in the Terminal you might want to post your share definition by doing this:

Open Terminal
Type net usershare info
If you had to become root to share a folder you may need to use the following command:
sudo net usershare info

Last edited by altair4 on Sun Oct 18, 2009 9:44 am, edited 1 time in total.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5802
Joined: Tue Feb 03, 2009 10:27 am

Re: Simple File Sharing in Mint

Postby SallyK on Sun Oct 18, 2009 3:54 am

Thank you very much for coming back to me so quickly.

The output from the parm command is

Load smb config files from /etc/samba/smb.conf
Processing section "[printers]"
Processing section "[print$]"
Loaded services file OK.
Server role: ROLE_STANDALONE
[global]
server string = %h server (Samba, LinuxMint)
map to guest = Bad User
obey pam restrictions = Yes
passdb backend = tdbsam
pam password change = Yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
unix password sync = Yes
syslog = 0
log file = /var/log/samba/log.%m
max log size = 1000
dns proxy = No
usershare allow guests = Yes
panic action = /usr/share/samba/panic-action %d

[printers]
comment = All Printers
path = /var/spool/samba
create mask = 0700
printable = Yes
browseable = No

[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
force user = maria


And the usershare set up is:

[data_folder]
path=/home/maria/data
comment=
usershare_acl=Everyone:F,
guest_ok=y


I'm not trying to do anything with root at the moment, this is just sharing the data partition, which is automounted in home.
User avatar
SallyK
Level 3
Level 3
 
Posts: 177
Joined: Fri Oct 02, 2009 5:22 pm

Re: Simple File Sharing in Mint

Postby altair4 on Sun Oct 18, 2009 8:14 am

Yep, Having the "force user" at the end, places it in the [print$] section which will do absolutely nothing :oops: It needs to go in the [global] section. Fore purely aesthetics reasons I would personally put it after the "usershare allow guests" line just so I knew why I added the line but it can go anywhere in the [global] section:
log file = /var/log/samba/log.%m
max log size = 1000
dns proxy = No
usershare allow guests = Yes
force user = maria
panic action = /usr/share/samba/panic-action %d

I do apologize for that and I will amend my first post to correct for this omission.
One thing I did notice is that step (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." didn't seem to happen, it just created the share

I suspect that your mountpoint - /home/maria/data - is for a windows filetype ( FAT32 or NTFS ). Usershare's ability to change permissions only works with linux filetypes so you would have to change permissions in fstab for that mountpoint.

However changing the "force user" location should work around this problem. If it doesn't, post the fstab line that defines how you are automounting the /data partition.

EDIT: If the "force user" doesn't work and it's not a windows filetype then please post the output of the following command:

ls -dl /home/maria/data.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
altair4
Level 15
Level 15
 
Posts: 5802
Joined: Tue Feb 03, 2009 10:27 am

Re: Simple File Sharing in Mint

Postby SallyK on Sun Oct 18, 2009 11:07 am

Thank you very much - moving the force user line has solved the problem. :-)

I think the difficulty is that the smb.conf has so much commentary, to explain what it is doing, that it's difficult to actually see the lines that are active and not commented out. (At least in gedit, I don't know if there's some other editor that would make it easier.)

Don't worry about it if you have something better to do, as I say the problem is fixed, but I am curious as to why the Nautilus dialog box didn't come up, as the partition is ext3 formatted. (It's just to share files between Mint and Kubuntu.)

The output from the command you gave me is
drwxrwxrwx 16 maria users 4096 2009-10-18 15:56 /home/maria/data


In any case, thank you for your time in getting this sorted out.
User avatar
SallyK
Level 3
Level 3
 
Posts: 177
Joined: Fri Oct 02, 2009 5:22 pm

Re: Simple File Sharing in Mint

Postby Carpintonto on Sun Oct 18, 2009 1:09 pm

thank you altair4 and SallyK very much.

For me, nautilus-share has always been broken on two Gloria desktops.
shares-admin interestingly does appear on the icewm menu.

On the machine running the gnome desktop I use the run dialog invoked by Alt-F2 to run shares-admin.

Even it has a few quirks. I have to share the /home/user folder before I could share a folder below /home/user.
Then I could delete (from shares!) the home/user folder and just share /home/user/Shared
Carpintonto
Level 1
Level 1
 
Posts: 21
Joined: Tue Jun 30, 2009 7:44 pm
Location: Kellogg Idaho

Linux Mint is funded by ads and donations.
 
Next

Return to Tutorials / Howtos

Who is online

Users browsing this forum: Google [Bot] and 14 guests