Wow the documentation for this is so confusing mainly because most of the google things don’t cover how the latest release of Ubuntu actually works. The good news is that many things are now automatic. So to cover the tricks and traps here;

Ubuntu file sharing via SMB

This actually as easy as the Mac now that we are up to Trusty Tahr 14.04. The good news is that:

  • Avahi-daemon. This is the thing that gives you local names is installed by default. So if you ping hostname.local then you should see all the ubuntu machines on your network. Same is true with all Macs. It is using bonjour underneath and the trick is that you need to add .local to the hostnames. I’ve found that this takes some time to work and items don’t appear super well or often in Mac or Ubuntu network browse. But you can check for existence with avahi-browse -a which is a command line utility installed by default
  • Avahi advertising of services. By default, Avahi appears to only advertise the network names for your machine. It doesn’t seem to advertise services. Many old posts talk about adding XML junk into /etc/avahi/services. One note is that unless you want lots of different apparent entities, you want to merge together all the file oriented (samba and afp) into a single file. However when I do a service avahi-daemon restart, nothing happened until I realized that the names of the files must end in exactly .service or avahi will not recognize it. The <a href="http://serverfault.com/questions/118237/how-to-use-zeroconf">avahi-publish-service</a> does however work and you can advertise http and other service, but this leaves a process running to do this.
  • Share file automatically installs Samba. Samba allows SMB sharing (get it :-). It does require an installation, but if you right click on a folder in the Unity interfaces, you get this and it does an install. It also has a check box for guest access. Under the covers what is happening is that a magic directory /var/lib/samba/usershares/ gets created. All the guides that talk about /etc/samba/smb.conf are in correct as the user shares have now moved here.
  • The confusing thing is user permissions. If you set it as guest allowed, then you can access anything, but Samba has its own notion of users (as there is no central user directory) which you set with smbpasswd and it is stored in a separate smbpasswd file so this is unlike the Mac where the password is the same also your user account.
  • In the Ubuntu user interface, it asks if you want to allow guest, this sets var/lib/samba/usershares/<sharename> with an entry guest=y and if you want other users to be able to change, it changes the permissions of the actual data folder to 777, so it looks like permissions are honored by the smbd (Samba server).
  • It is not clear what the default Samba password is. The guides aren’t very clear, but it looks like user security is quite different for samba, there is a smbpasswd command and it allows you to set local and remote passwords. By default, there are no samba users (which is strange). So you need to add a user. The user must also have a real account on the local machine, so do a sudo smbpasswd -a rich to add an existing user named rich to the smb password database. Then the user can do a smbpasswd to set his password. In search for the smbpasswd file, it looks like it is null at the beginning of using samba which is supposed to life in /etc/samba/smbpasswd or in a tdb database, it isn’t clear.
  • Also it is unclear how with the Mac once you’ve connected to a server, you can forget the user name and password. But there are a host of commands to get rid of the confusing “The server XXX may not exist or is not available at this time”. What is happening is that either the server is really down or more likely the Mac failed to logon properly. Argh. What a message. To see if this is the problem go to the Finder and choose CMD-K and type in manually smb://yourfileserver.local and see if you get a logon prompt. This verifies that the Finder is using the wrong credentials. You can also try to manually list what it has with `smbclient -L yourfileserver -U yourusername -d=2 and see what you get.

I’m Rich & Co.

Welcome to Tongfamily, our cozy corner of the internet dedicated to all things technology and interesting. Here, we invite you to join us on a journey of tips, tricks, and traps. Let’s get geeky!

Let’s connect