Working (or living) within a Linux-based network is become more and more commonplace. And with the popularity of Mac OS X rising, Apple-based computers have to play well inside a Linux network. With the help of Samba this is not only possible, it's easy to configure and establish. Let's take a look at how an OS X computer connects to a Samba share.
Before we get started I wanted to make note that this is not an in-depth article on setting up Samba. We will touch base on getting Samba up and running so the Mac OS X machine can connect to it, but primarily this is about OS X's ability to connect.
This blog post is also available in PDF form as a TechRepublic download.
Basic Samba configuration
The first thing you need to do is set up the Samba Security mode. This is located (in Fedora-based Linux distributions) in /etc/samba and the file is called smb.conf. You will have to have root access in order to make these modifications. So open up a console window, su to root, and open up the smb.conf file in your favorite editor.
The first option you are going to change is the workgroup option. Change this to match the workgroup you use on your network. The next option you need to do is change the security= option. We are going to change that option to security = user. The next option is the hosts allow option. You want to set this to the range used on your network.
For example: In my home network I use the 192.168.1.x address scheme. You might also want to allow for all localhosts.
comment = Home Directories
browseable = yes
writable = yes
read only = nopublic = yes
Now the above section can cause you some security issues. You will want to make sure your network is secure and that the data housed in this Share isn't critical information. Why? Because you are making it available to anyone that has a Samba login name/password. Granted you get a modicum of control by only giving Samba usernames/passwords to trusted users.
For basic Samba configuration that is all you need to do with smb.conf. Now you need to add Samba users and passwords. These users and passwords will be used when a user attempts to log onto a Samba share from the Mac OS X machine. To add a Samba user you will run (on the Linux machine as root) the smbpasswd command:
smbpasswd -a USERNAME
At which point you will be prompted (twice) to enter a password. Once that is done you are ready to fire up the Samba daemon. To start the Samba daemon issue the command (again as root) /etc/rc.d/init.d/smb start which will start up Samba. You should get no errors.
Now you are ready to hop on over to your Mac OS X machine.
Connecting from Mac OS XThe first thing you need to do is open up a Finder window. (Figure A)
Your standard Finder windowTo quickly start a connection hit the [Apple] key and the [K] key together. You will then be prompted to enter a server address. As you can see in Figure B, you will enter the actual server IP address preceded by smb:// once you enter the information click OK.
If you hit the + sign you can add this Samba server to your favorites list making connecting even easierNow you are ready to select your SMB mount point. As we have configured in smb.conf our only available mount point is homes as shown in Figure C. So click OK to continue.
If there are more mount points configured in smb.conf they will appear in the drop down listNow you will be prompted for the username/password you added with the smbpasswd command as shown in Figure D. Enter this and click OK.
Username and password
You can also add this username/password combination to your OS X keychain by clicking the checkbox. If this machine is shared, I do not recommend this option for security purposes.Once the machine has connected to the Samba share you will see the directories/files appear in the Finder listing as well as a representative icon on the desktop. (Figure E)
Because of the configuration in smb.conf your user should be able to read and write files to the Samba share
You are all set.Now in order to disconnect from the Samba share you simple do a Ctrl-click and select Eject "HOMES" from the options. (Figure F) Once you do that your machine will disconnect from the Samba share.
Another method of disconnecting is to click and drag the icon to the trash bin on the dock. You can also click the eject button associated with HOMES in the Finder.
Connecting an OS X machine to a Samba share couldn't be any easier. Just remember to keep your security tight so that rogue users cannot gain access to your Samba shares. If you have more complex needs with Samba make sure you visit the Samba Web site for more information.
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.