After a few fairly theoretical Hot Cocoa columns (on the human interface aspects of the Dock and the Finder) this week's column lands squarely back in the "How-to" realm with a look at using Samba/CIFS to share files between Mac OS X and Windows machines. We have already covered some of Mac OS X's many means of sharing files in previous Hot Cocoa columns: from Web serving to using Apple's built-in AFP (Apple File Protocol) and controlling access levels using users and groups, Mac OS X already has a lot of built-in clout in the filesharing department. In addition to the means we've already covered here, it is also possible to use Mac OS X's built-in FTP (File Transfer Protocol) server, its Unix-based NFS (Network File System) and its high-security SSH suite (which provides secure FTP, copying and shell access). This level of included functionality is unparalleled in other desktop operating systems and is an exemplar of Apple's wisdom in deciding to build their new OS on top of an industrial-strength Unix foundation.
This week's column is about yet another method of sharing files, and this one specifically targeted at sharing files with Windows machines (which is, after all, probably the most likely type of sharing that most Mac OS users will have to master in the business world). I'll describe the tools that my colleagues and I have successfully used to implement file-sharing between machines on our heterogeneous network containing one Windows 2000 and two Mac OS X computers. The name for the technology I will be discussing is "Samba," or to use Microsoft's official parlance, "CIFS" (Common Internet File System). Of course, there is little that is "common" about Microsoft's proprietary implementation of file sharing, but that's a debate for another day... Rather than trying to force the Windows machine on the test network to speak "Apple," we figured it would be easier to go with the flow and get our Mac OS machines to speak "Microsoft."
This kind of thing was also possible under Mac OS 9, but it required proprietary commercial software solutions such as Thursby's Dave and Miramar System's PC MACLAN. Thanks to the Unix underpinnings of Mac OS X, CIFS filesharing can be implemented using products that are either freely available or inexpensively priced.
Because CIFS is a native protocol on Windows, no special software was required for the Windows 2000 machine on our network. Our Mac OS X machines, however, required two components: firstly, a server application that would allow the Windows machine to access the files on the Mac OS X box, and secondly, a client application that would allow the Mac OS X boxes to access files on the Windows machine. We'll briefly deal with the server first.
The open-source Samba project comes to our rescue here by providing a free server solution that works perfectly on Mac OS X. (Although users of the standard version of Mac OS X must download and install Samba, those who have purchased Mac OS X Server will find that Samba is not only preinstalled by default, but is easily configurable through the Apple-provided administration interface.)
Luckily for us, Samba is easy to install and configure. There is no need to compile the code manually, nor is there any requirement to edit the arcane "smb.conf" configuration file by hand in the Terminal. (For the curious, however, you can take a look at the smb.conf file after Samba is installed -- it's located at /usr/local/samba/lib/smb.conf...)
The Samba X 2.1 package provided by the Xamba project at Sourceforge is a 5.4 megabyte download and it contains everything you need to get up and running with Samba on your Mac OS X box. To quote from the Samba X site:
Samba X is no more than Samba, but wrapped in an easy to use installer package. You only need to double click and you are up and running. The current release is based on Samba 2.2.0.
An invaluable tool to accompany Samba X is Samba Server Config Tool (SSCT) (also produced by the Xamba project). The download is less than a megabyte and it contains a graphical front end for configuring the aforementioned smb.conf file. We'll need to do two things with SSCT to get Samba properly configured on each Mac OS X machine:
- Under the "Server" tab of SSCT we choose a unique computer name for each machine, supply a "computer string" (an optional comment describing the machine) and then specify a "workgroup".
The name you choose for the workgroup is arbitrary but it is conventional for workgroups to be include only capital letters (no spaces). All machines on the network must belong to the same workgroup in order to "see" each other and share files via CIFS. There is no need to enter a "WINS" server if you are only going to be sharing files among a small workgroup.
- Our next step is to define "shares" under the Shares tab of SSCT. In this step we choose the items on our hard disk that we wish to make available to other people in our workgroup. Once again, we specify a name of each share, an optional, descriptive string about each share, and enter the path on the hard disk to the share (note that SSCT allows you to browse your folder hierarchy by pressing the "Edit" button -- there is no need to type the paths in by hand.
Note that it is possible to turn on guest (password-less) access and also grant write permissions. In the case of my own LAN (Local Area Network) I am behind a firewall and it is therefore safe to turn on guest access. Nevertheless, use this switch with caution! If you are not protected by a firewall and are connected to the Internet then anybody in the outside world could access your shares.
Once you've configured Samba using SSCT (clicking the lock and entering your administrator password if necessary) you can start it by clicking the "Start" button under the Server pane in SSCT. At this point any Windows machine in your workgroup will be able to see and access your files. You'll find that long filenames (more than 31 characters long) are properly preserved, as are special characters. In my experiments so far I have discovered that aliases are not exported properly, so if you want Windows clients to see your files you'll have to make sure that you share the actual files and folders, not just aliases to them.
Now that we've set up our server, we just need to install a client so that we can access the files on the Windows machine(s). This article will assume that each Windows machine has had its sharing properties set so that the appropriate workgroup name is specified (the same workname as you chose when using SSCT above) and that the desired files and folders have their sharing attributes set.
On the Mac side of things you can use Sharity by Objective Development to turn your machine into a CIFS client and provide you with a neat graphical interface as part of the bargain. Sharity is available in a free demonstration version (which permits you to install it on one machine on your network and access one Windows CIFS server with it), a free student version (which allows you to install it on two machines on your network and access two CIFS servers) and finally with a home license (allowing two installations and unlimited servers) for $59 or a business licence with various options starting at $99.
To start with, download the home/demonstration version. The download is 2 megabytes in size. Installation is simple; just follow the included instructions and add Sharity to your Login items using the System preferences application.
Although Sharity comes with a potentially daunting user Interface, in practice using it is actually very simple. Without any configuration you can access the shares on other machines just by clicking through the Finder. To start you will need to open a Finder window and click on the "Computer" shortcut in your toolbar. From there, go to "Network", and then "CIFS". You should see all of the machines on your local network in your workgroup. Double click on them to access their shares. If your windows machines have been configured to require passwords, enter then in the window that pops up -- otherwise just leave them blank. Voila! Instant access to your Windows files from the comfort of your Mac desktop!
There is one caveat with this procedure. If you find that you are not able to access shares as described above there may be an incompatability between the version of Windows that you are trying to access and your machine. This is a well known problem wherein Microsoft has intentionally "broken" its CIFS module in particular versions of Windows so as to ensure that it doesn't work with Unix-based Samba clients and servers. There are two workarounds:
- Alter the registry on the Windows machine to disable encrypted passwords and thus workaround the problem introduced by Microsoft (see the workarounds for Windows 2000 machines, Windows 95 and 98, and other NT machines).
- When entering your password in the Sharity dialog, toggle the setting in the "Send passwords encrypted" checkbox.
With these simple tools you can turn your Mac into an easy-to-use Mac-to-Windows filesharing machine. The ease with which this can be done is a testament to the power of Mac OS X and the versatility of the Unix core at its heart.
Using the system I have been able to set up a network where the Mac OS X machines could share files both ways (as server and as client) with Windows machines and with other Mac OS X machines -- all using CIFS and freely available tools.
Watch this space for my next column, where I look at NFS, the filesharing system that has long been dominant in the world of Unix.