Goal: I have been wanting to configure a file server for my Windows 7, Windows XP, and Mac OS X Lion home network environment. I got tired of trying to make Windows shared folders to show up in Finder and visa versa.
Just so happens my parents old eMachines decided to die a few months back, naturally I took it home to see what I can salvage from it. Turned out all it needed was a new power supply. $28 bucks later and after I slapped a spare 320GB Hard Drive in it, I had a perfect file server. Of course I put Ubuntu on it because that’s what all the cool kids do. So my file sharing to Mac OS X began…
NOTE: In Mac OS X Mavericks, Apple has shifted from using AFP in favor of SMB2. I will update this post once I figure out how to get Ubuntu and Mac to talk to each other. In the mean time please hold off on configuring this if you are using Mavericks. Any suggestion are welcome in the comments below.
1. Install Netatalk
Netatalk is the Open Source implementation of AFP, Apple file Sharing Protocol. Simply open Ubuntu Software Center and search “netatalk”.
Open up Terminal. Run the following command:
sudo gedit /etc/default/netatalk
sudo command is the Windows equivalent of “Run as Administrator”. It gives you elevated privileges, which is what you will need to modify system files. The next command
gedit opens Ubuntu’s native text editor. The next command
just specifies the file path
Edit the netatalk file to match the code below
Then close and save the document. Next we have to edit the main config file for AFP sharing called afpd.conf:
sudo gedit /etc/netatalk/afpd.conf
Scroll down to the very bottom and add this to the bottom (If there is already a line there, replace it with this one):
- -transall -uamlist uams_randnum.so,uams_dhx.so -nosavepassword -advertise_ssh
Save and close the document.
2. Install Avahi
Avahi advertises all defined services across your network just like Bonjour does. It will let your Mac automatically discover your Ubuntu box in Finder.
sudo apt-get install avahi-daemon
Now we have to edit the nsswitch.conf file:
sudo gedit /etc/nsswitch.conf
All you have to do here is add “mdns” at the end of the line that starts with “hosts:”. It should look like this:
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns
Save and close the document.
Now we can tell Avahi to behave like Bonjour and advertise certain services. In our case we just want to advertise AFP sharing. A simple XML file can accomplish this. Run the following command:
sudo gedit /etc/avahi/services/afpd.service
A new document should open in gedit. Now paste the following into that new document and save the file:
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
Restart Avahi daemon
sudo /etc/init.d/avahi-daemon restart
That’s it! You should now see your Ubuntu box show up in Finder. Beautiful.