Posted by: reformedmusings | May 22, 2010

Samba file sharing in Ubuntu Lucid 10.04 LTS

I’ve been struggling to get Ubuntu Lucid 10.04 LTS and  Samba to play nice together. Everything seemed to work fine in Karmic, but it seems that somehow the rules changed under Lucid. If you just upgraded from Karmic to Lucid and everything worked fine in Karmic, jump down to the bottom of the post and try my suggestion in the last paragraph about Samba user names and passwords. If that doesn’t fix you up, then you’ll have to work through the post and see what else might need to be done.

Before I start, I have to reiterate the core comment made on this site about share permissions. Ubuntu and Samba sharing permissions must both be set correctly, plus the Ubuntu system folder and file permissions must be tailored appropriately,  for sharing to work correctly. Otherwise, one will negate the other and sharing won’t work. That’s overriding lesson #1.

Lesson #2 is that in Lucid, at least as of today, they do not share user names or passwords. There’s a dialog in the Samba setup GUI for them to do that, but it apparently doesn’t work right. I do provide a workaround below.

Of course, one could use Network File System (NFS) rather than Samba if you only want to share amongst Linux machines. However, I want my Windows Mobile Smartphone to be able to connect to my desktop through my WiFi router, so I need to use Samba for that. Rather than have both protocols running, I chose to stay with Samba.

This will be a long post which takes you from zero to network sharing, so strap in…

Samba setup

Samba version 3.4.7 is distributed with Lucid through the repositories. To make it work, you need to install a number packages and their dependencies, one being a GUI interface (which has at least one issue that I’ll cover later). From the terminal, that would look like:

sudo aptitude install samba samba-common-bin system-config-samba smbfs smbclient

You can also choose these in Synaptic. The packages will install supporting packages like samba-common. Do you need ALL these packages? I’m not sure to be honest. I ended up installing them all in the process of getting the network sharing to work, and I’m not about to go uninstalling any at this point.

The system-config-samba GUI shows up under System -> Administration -> Samba:

The screenshot shows my existing shares (second one blanked out in part). First we have to setup the server and create Samba users, which should parallel the users on the Ubuntu system. Click Preferences -> Server Settings…

If you’re going to share with a Windows system, WORKGROUP is the default workgroup. You can change it, but I just left it. Click on the Security tab:

Here I chose to use User authentication and to encrypt passwords to increase the security posture. I also disabled guest accounts. Guest accounts are a favorite target of intruders and are best left disabled. Click OK to save any changes.

Next on the home screen, go to Preferences -> Samba Users:

Add a user by clicking on Add User:

Now, this should have been all that’s required to tie an Ubuntu user to a Windows share user, but it wasn’t. I’ll get to that later. In fact, I cannot honestly say that adding users here did anything at all because sharing didn’t work until I manually added the necessary users and passwords from the terminal. Either I’m missing something or there’s something amiss in the GUI.

To add a share, simply click the Add Share button on the home screen:

This screenshot actually shows the properties of a share so that you can see the net result. Simply browse to the folder that you wish to share, give it a name that means something to you, and choose whether you want it to be visible to and/or writable by others. Then you need to click the Access tab to choose with whom you wish to share the folder:

The share users MUST already have been created as shown above (I think) or exist on the Ubuntu system. If they don’t exist in Ubuntu, you’ll have to create them through System -> Administration -> Users and Groups before adding them here. If you “Allow access to everyone”, you’re opening your share up to the whole network – not something I’d recommend doing unless that’s what you really want. Click OK and you’ve created a share.

That should be it for Samba, but unfortunately was not in my case and many others as I found out on the web. Apparently there’s one more step needed. You need to add users and their passwords from the terminal:

sudo smbpasswd -a USERNAME

Do that for each share user. I believe that adding users in the GUI should have done the same thing, but apparently it didn’t take for me or a number of other folks.

Ubuntu Lucid steps

The above is only half of the equation. Now we have to properly configure Ubuntu for sharing. The most obvious step is to go to System -> Preference -> Personal File Sharing and click the top choice “Share public files on network”:

The problem will be that most likely that option will be grayed out when you first go there. That’s an interesting mystery in Linux file sharing, as there’s no clue as to why except the cryptic declaration that you don’t have the necessary packages installed to enable network sharing. But, it doesn’t tell you which packages you need! Searching the repositories will not help. I found out by Googling and finding this bug report. Down in post #11 there, Baptiste Mille-Mathias provides the list of three packages that enable sharing. You can install them with Synaptic or in the terminal:

sudo aptitude install apache2.2-bin apache2.2-common libapache2-mod-dnssd

That’s part of the apache web server. Why you need to install the web server to share files goes way beyond me. But you do and installing these packages indeed enables network sharing. You can then check the Share public files on network box. Then click closed.

Now we need to choose the individual folders in Nautilus to share. Right click on a folder that you wish to share:

Then click on Sharing Options as shown above:

Click on Share this folder, then give it a name and decide the permissions that you wish to grant and click on Create Share to save your settings. Nautilus should then put a sharing icon on that folder:

But that may not grant access to all the files and subfolders in the share folder. You have to ensure that your Linux user permissions match your sharing objectives. For example, I right-clicked on my Share folder and then clicked on Properties and went to the Permissions tab:

I wanted sharers to be able to create and write files in the share folder. So here in the Permissions dialog, I need to ensure that the Ubuntu folder permissions match my sharing desires. So, I set Group and Others permissions to Create and delete files. That’s not the normal default permission set,  nor should it be. Linux is very security conscious, and defaults to the minimum permissiveness required.

If I had a large number of sharing users or machines, I would create a sharing group, put all sharing users in it, and set the folder permissions appropriately for that group. That way, I wouldn’t have to open up the permissions for the Others category in the dialog.

After setting all the permission appropriately for your circumstance, click on Apply Permissions to Enclosed Files, otherwise the new permissions will not be propagated to the files and subfolders in the shared folder. This is probably the most commonly missed step in setting up a share folder.

That should do it. At this point, you need to accomplish these steps on the other computers on which you have folders that you wish to share.

End game

Once all your computers are properly configured, simply go to Places -> Network to bring up the networks available:

Double-click on Windows Network:

This lists all the workgroups available. Double-click on WORKGROUP:

This lists all the servers available in the workgroup. Double-click on one to access the shared folders:

Success!

Closing comments

I found a few good web posts that provide helpful hints on Samba sharing in Linux. I tried a few of their suggestions, but other than the manual addition of Samba users and their passwords they didn’t make any difference. But that may not be true for everyone. Jonathan Moeller seemed to have the best summary of how to get Samba working using the terminal and editing /etc/samba/smb.conf directly. The link I provided at the beginning of this post about permissions also had some good inputs.

I think that when all was said and done, all I really had to do to transition my working Samba setup from Karmic to Lucid was to manually input the Samba user names manually from the terminal using smbpasswd as described above. There’s no way to know that for sure now. I still had to go through all this on the laptop since I had to do a clean install on it. In any event, it all works now.

Advertisements

Responses

  1. […] firewall settings with Samba and Ubuntu Lucid 10.04 LTS In my previous post, I talked about how to setup up network sharing with Samba and Ubuntu Lucid 10.04 LTS. Although I […]

  2. […] seemed to work fine in Karmic, but it seems that somehow the rules changed under Lucid. More here If you just upgraded from Karmic to Lucid and everything worked fine in Karmic, jump down to the […]

  3. […] o problema de compartilhamento das pastas. Estava googlando e encontrei um  artigo chamado “Samba file sharing in Ubuntu Lucid 10.04 LTS” do blog de , que resolveu o meu problema, então resolvi postar uma tradućãoo do mesmo. […]

  4. HI, I’ve posted a translation to pt-br of this article on my blog. It was very useful. Thanks!

  5. You are welcome! Thank you for translating it for others to benefit.

  6. Thanks a bunch for posting this. I wonder what changed from Jaunty to Karmic to Lucid that is messing up the samba installs… Some things should not be touched as they are working fine already!!

  7. You’re welcome. The first rule of development used to be “if it ain’t broke, don’t fix it!” Not so much anymore.

  8. Thanks a lot, my samba shares are now up and running, however, im unable to create user groups for samba and some of the sub files in my shared folders come as read only for some of my users despite giving these users write privileges, could you please point me in the right diretion?

    Regards

    • The only thing that I can offer is to follow the steps that I outlined above. On the files, it sounds like you did not click the box that says “Apply Permissions to Enclosed Files” for the appropriate parent folders. For adding users, the user creating new Samba users must enter their sudo password first. The creating user must have permissions under Ubuntu associated with sharing and file systems. I’m not sure exactly which ones you need, so just check them all for the administrator. Again, follow everything in this post exactly.

  9. […] netseer_network_id = 1040; [Log in to get rid of this advertisement] Hi folks, Followed this https://reformedmusings.wordpress.com…cid-10-04-lts/ And all was fine. yesterday, I notced I had not updated things for awhile. Now I just get the […]

  10. […] has died, yet again, on here Works just fine after I followed the information on this link. https://reformedmusings.wordpress.com…cid-10-04-lts/ The problem I had was I could not log in with a valid user and password. This tutorial fixes this […]

  11. I just wanted to say thanks. Everything is working now. I have been banging my head against the wall trying to get it going.

    • Thank you for writing. I’m very happy that it worked out for you. I understand well the head banging part.

  12. I didn’t need to do anything after: “Now, this should have been all that’s required to tie an Ubuntu user to a Windows share user, but it wasn’t. The “Edit Samba share” wasn’t necessary.

    It worked like a charm. However, I have to add, that I had already added share attributes to the folder I wanted to share. Thanks for the first part, it made it clear and worked right away.

    • Excellent. I’m glad you’re up and sharing. Thanks for taking time to write.

  13. […] […]

  14. […] I run my PC 24/7. I use Ubuntu Lucid 10.04 to serve up the household printers and network the Dell Ubuntu laptop for backup purposes, so turning off my PC isolates the laptop. When we go […]

  15. When I try to access the windows network it comes up with an error: Unable to mount location, failed to retrieve share list from server. Would you happen to know how to correct this?

    • Have you set up sharing for the Windows location that you wish to access and have the permissions there set properly? That’s the first thing that comes to mind. What version of Windows are you using on the share target?


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: