Tweets:

Posting tweet...

Powered by Twitter Tools

Bonjour / AVAHI & Netatalk to share files files between Ubuntu 10.4 & Mac OS X

It use to be somewhat difficult to have Filesystems on an Ubuntu system show up on the Mac Finder the same way that other Mac Filesystems would show up. There has been the Open Source Unix implementation of the Apple File System (afp) but for a long time the Ubuntu packages were not properly configured to work transparently with modern (Snow Leopard) Mac OS X.

One blog post, HowTo: Make Ubuntu A Perfect Mac File Server And Time Machine Volume did a great job going through all the steps needed to build Netatalk from source and configure it to work very transparently with Ubuntu releases of the past. But with the Ubuntu 10.4 Lucid release, the Netatalk that is in the Ubuntu repository is built and configure to support transparent Apple File Protocol based file sharing.

But there are a few configuration issues, mainly with the Unix implementation of Bonjour resource discovery protocol, that still needs to be done to make it so you can see your Ubuntu Filesystems on your Mac’s Finder like other Macintosh instances. Also we’ll see how to make it so that the Ubuntu instance will show up as an ssh server as well.

Installing Packages

You will need to install the following packages onto your Ubuntu 10.4 instance. This assumes that you already did a clean install of Ubuntu 10.4 and used the update manager to bring it up to date. If you have already installed some of these, it should not be a problem.

Install ssh server

I can’t believe that ubuntu doesn’t install an ssh server by default. But in any case its pretty easy. This is not needed to use netatalk but I wanted to make ssh and netatalk to work and be available via bonjour.

sudo apt-get install openssh-server

Then you’ll need to set up your authorized keys on the ubuntu server. In your home directory do the following:

mkdir -p .ssh
# Copy your public key[s] to .ssh/authorized_keys (not shown here)
# Set the permissions to only allow your user to access the .ssh directory and files in there
chmod -R og-rwx .ssh

Install Netatalk

sudo apt-get install netatalk

Configure Netatalk

You don’t need to change any of the configuration files for netatalk. The defaults will enable the sharing of your home directory. If you want to share any additional filesystems from your Ubuntu instance to your Macs, you can add them to the /etc/netatalk/AppleVolumes.default. That file has explanations of al the options.

You may want to change the default last item in /etc/netatalk/AppleVolumes.default from:

~/			"Home Directory"

to something like:

~/ "$h_$u Home Directory" options:upriv,usedots

This will change the name that shows up in listing to be “hostname_username Home Directory” and will use Unix Privilages. Most importantly the usedots says to not do Hex translation of dot files. If you don’t do this, you’ll see things like
:2e_somefilename instead of .somefilename where filenames start with “dot”.

Configure AVAHI

AVAHI is probably already installed if you did a standard installation.

Copy the avahi ssh service configuration into /etc/avahi/services

sudo cp /usr/share/doc/avahi-daemon/examples/ssh.service /etc/avahi/services/

Create an avahi afpd service configuration by creating a file /etc/avahi/services/afpd.service with the following content:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">%h</name>
  <service>
    <type>_afpovertcp._tcp</type>
    <port>548</port>
  </service>
  <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <txt-record>model=Xserve</txt-record>
  </service>
</service-group>

You should now be able to see the Ubuntu host in your Finder under the SHARED section on the left side of the Finder. You should also see your Ubuntu host in the “New Remote Connection” window of the Mac Terminal app (CMD-SHIFT-K) if you select the “Secure Shell (ssh)” Service.

If you don’t see the Ubuntu hostname in the FInder or in the Terminal New Remote Connection service,  restart the avahi-daemon service:

sudo restart avahi-daemon

TimeMachine Support

The new Ubuntu Netatalk package is supposed to also support TimeMachine storage. You can enable this in /etc/netatalk/AppleVolumes.default and add tm as an option to the filesystems that is published in this file. I have not tried this and many sources consider this a risky way to store Time Machine backups.

Troubleshooting

You should make sure that there is at least one afpd process running on the Ubuntu instance. You can see the log info in /var/log/daemon.log.

That’s it!

6 comments to Bonjour / AVAHI & Netatalk to share files files between Ubuntu 10.4 & Mac OS X

  • Nik Carrier

    I am not very skilled at linux terminal work…i keep trying, but usually get frustrated and drift away after a while. I have tried many of the guides to get an AFP share up and running on ubuntu, but no matter what I try security of some sort always shuts me down. (I know it is not wise in security, but I wish you could turn all permissioning off and add layers back on later after things are running)

    I’ve followed both your steps and an older guide that seemed to work as well (though i don’t use or care about time machine support)…I get the server listed in Finder and when I try to connect to it I am always told my password is invalid and I cannot connect. I know you probably need more info about my system to properly diagnose the issue, but I wouldn’t know where to look without instructions. Any info you could provide to prevent me from turning this PC into a crappy SMB/Windows box in the closet would be helpful Been researching and experimenting all day and am getting frustrated again …thank you :)

  • @Nik: I’m not sure what causes that. I think its happened to me too, but a while ago.
    Do you have another Mac computer you can use to see if you can at least do AFP from your one Mac to another as a reality check on your network and other assumptions?

    But back to the Mac to Linux connection:

    I can’t remember where the target Linux Machine gets its authentication credentials from. I think its from the Linux User. So did you try using the user name and password of your target Linux Machine and not the Mac you are on?

  • worked like a charm.. Thx! :)

  • Emma

    I have my ubuntu computer connected to my router via Ethernet cable. Would my ubuntu machine need to be wirelessly connected to the network in order for me to take advantage of it’s server capabilities on my MacBook, which is connected to the same network, only via wifi?

  • willisweb

    @Nik: The user details the Mac connects with are the Linux users usrname/password. To keep things simple you could just add a new user to the Linux box with your Mac username and password…
    sudo adduser your_mac_username
    …and just answer the questions as they come up

    @Robert: Thanks very much for posting this tutorial, most others on the net refer to earlier versions of Ubuntu and things have moved on a bit since then

  • @Emma: It should work via Wireless or wired Ethernet. Of course the performance should be much better with wired Ethernet.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>