Saturday, January 19, 2008

OS X <3 Ubuntu

Update: in newer Debian packages, new authentication methods are available. Under Ubuntu 9.04, I edited /etc/netatalk/afpd.conf to specify -uamlist=uams_dhx2_pam.so,uams_dhx2.so, added the service to avahi, and I was able to mount my homedir over AFP. No re-compling necessary!

One project I have been sitting on for a while was to get file sharing by AFP and Bonjour working between by MacBook Pro and my Ubuntu machine. Well, faced with the prospect of actually doing homework, I suddenly found the time to do it today.

The end steps were really simple... the main sources I consulted were two threads on the Ubuntu forums, and one page on the Gentoo wiki. Update: see also this excellent guide.

The instructions boil down to this:

1. Build the package netatalk from source, enabling ssl.

I was not able to get my MacBook to connect to my Linux machine after I did an "apt-get install netatalk". A little digging showed that the Debian license (and hence the Ubuntu license) do not allow building with OpenSSL. Okay, an easy fix [1]:

$ mkdir -p ~/src/netatalk
$ cd ~/src/netatalk
$ sudo aptitude install devscripts cracklib2-dev dpkg-dev libssl-dev
$ apt-get source netatalk
$ sudo apt-get build-dep netatalk
$ cd netatalk-2.0.3
$ DEB_BUILD_OPTIONS=ssl sudo dpkg-buildpackage -us -uc
$ sudo debi
$ echo "netatalk hold" | sudo dpkg --set-selections

(Update: added netatalk hold, thanks to Damon Timm's guide.) Nice.

2. Install Avahi [2]

sudo apt-get install avahi-daemon avahi-discover avahi-utils libnss-mdns service-discovery-applet mdns-scan


Done.

3. Create a service file for AFP [2].

sudo echo >> /etc/avahi/afpd.service
<?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-group>
^D


At this point, the box should pop up in the Leopard finder:


Just for kicks, here are some bonus Avahi service files:

/etc/avahi/services/ssh.service
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_ssh._tcp</type>
<port>22</port>
</service>
</service-group>


/etc/avahi/services/sftp.service
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_sftp-ssh._tcp</type>
<port>22</port>
</service>
</service-group>


Here is iTerm happily showing my SSH and SFTP services on both my MacBook (goto) and Ubuntu machine (color):



[1] http://ubuntuforums.org/showthread.php?t=410274
[2] http://ubuntuforums.org/showthread.php?t=218630
[3] http://gentoo-wiki.com/HOWTO_Share_Directories_via_AFP

No comments: