Okay, so you have a shiny new Linux box, and it’s running Samba, all nice and configured to share your files. You have a Mac, and you want to use it with your nifty new Windows shares. You can connect with Command-K in the finder, but it doesn’t show up in Finder under the Shared section.
You need Avahi.
I won’t bother going into the details of configuring Samba. If you’ve not gotten that far, there are some pretty good resources out on the ‘net that will tell you how. Where interacting with Bonjour is concerned, however, most of the references I found were flat wrong with modern OS X and Samba.
To make this work, the steps are simple (I’m running Ubuntu 12.04, so you may have to adjust accordingly for your Linux distro of choice). The first step is to install Avahi:
root@core:/# apt-get install avahi-daemon avahi-utils
When this command completes, you’ll essentially have Bonjour running on your Linux box. This has a number of advantages, most notably that you can now log into the thing by hostname (eg. core.local for my machine) without having to configure DNS. But it still won’t allow you to browse shares in Finder; for that, you need a bit of configuration.
And so we move to step 2: create a file in /etc/avahi/services called smb.service, and place the following content in it:
<?xml version="1.0" standalone='no'?> <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">%h</name> <service> <type>_smb._tcp</type> <port>445</port> </service> <service> <type>_device-info._tcp</type> <port>0</port> <txt-record>model=RackMac</txt-record> </service> </service-group>
Upon saving it, your new Linux box will happily appear in the Finder sidebar, and should all work. You don’t even need to restart Avahi; it’ll pick up the new service file automagically.
There are other references out there for how to do this, but they all use port 139 – which doesn’t work. I haven’t a clue when Microsoft changed the port number, but whatever; I don’t really care. I have finder browsing goodness, so I’m happy.
Someday I may do a developer-oriented piece on the wonder that is Bonjour…
I’ve successfully set up netatalk to share the filespace from the Linux (Ubuntu) machine with my macs, and would like to set up screen sharing interface in the Finder now. Any ideas? I can use the connect to server option with vnc://ip.address to access the Linux machine, but I would like to access it like any other mac in the network. I was wondering if I can add an Avahi service?
thanks, Mike.
See new post. HTH.
S.
I was forced to issue:
sudo restart avahi-daemon
after making the changes detailed here before my “shared folders” showed up on my wife’s iMac.
Thanks for your help!
Thanks for this info. Just what I needed, and still works in 2015
Sorry, spellchecker changed my URL but I can’t edit it.
Thanks a lot!
I was digging for some time to got this working.
Now i’m looking for the same but for windows to see my smb, do you know somehow?
This was working beautifully for me, but now is not. I have macs running 10.9.5 all the way to 10.13.3. none of them can connect via the sidebar in finder. The server shows up in the sidebar (it is ubuntu 16.04), and when i click on it, it just states connection failed, when i use the connect as button, and enter the correct credentials i still get connection failed. If i connect using finder cmd+k, i can connect using smb://ipaddress or smb://servername or cifs://ipaddress or cifs://severname without issue. I have tried reinstalling avahi, but nothing changed. Any help appreciated.
Did you ever find a fix for this? I’m having the exact same issues
I removed netatalk from the server and everything returned to normal. For some reason it was interfering. Not sure why. I was using it for time machine afp shares. If anyone knows why the two don’t play well together please comment. I would really like to have both running so I can have my time machine backups on the ubuntu server.
Have run into a similar issue, but when I came across the page below, I found a solution:
https://holyarmy.org/2008/01/advertising-linux-services-via-avahibonjour/
It seems you need differentiate the services by name.
In my afp.services file I now have a line:
%h (afp)
and in smb.services it reads:
%h (smb)
Now both appear in the sidebar, and both are browseable.
The article is much informative which i was searching for .Nice intro good explanation thanks for sharing.