Friday, December 7, 2007

MY Book western digitl for macintosh: Using SMB on OS X

Using SMB on OS X

Though programs like Sharity and Dave have allowed Mac users to access SMB shares for a while now, it wasn't until Mac OS X 10.1 that SMB capabilities were built right into the OS. There are two ways to mount an SMB share in OS X. One method is to use the Finder, and the other uses the mount command from within a Terminal window.
Using the Finder

To mount a share using the Finder, you will need at least Mac OS X 10.1. Previous versions of the OS do not contain the necessary features to support accessing SMB shares natively. The first step to mounting the share is to select the Go menu and then select Connect to Server. The Finder keyboard shortcut is Command + K. This will open the Connect to Server dialog box. In this box there is a field labeled Address. In this field you want to enter:


Then click the Connect button. If all goes well you will be presented with the SMB/CIFS Filesystem Authentication window. This window will list the workgroup, username, and server used in the previous window. What you will need to do now is enter the appropriate password and then click OK. When done correctly, you will now see an icon on your desktop that is labeled with the name of the share you just mounted. You should now be able to use the share just like any other drive on your system.
Using the Terminal and mount

The second method of mounting an SMB share in OS X is to delve into its UNIX roots and use the command-line interface. First, open up the Terminal. To do this, double-click on Macintosh HD, then on Applications, then Utilities, and finally, Terminal. This will open up a command line session on your Mac and present you with a prompt. To mount the share, you will first need to create a folder to attach the share to. To do this, use the mkdir command as follows:

% mkdir myshare

For you to mount the share, you need to be logged in as root. Once you've created the directory, su to the root user, then enter the following command:

# mount_smbfs -W myworkgroup //username@netbiosname/share ./myshare

This will mount the remote share as the myshare directory, which means that it will not appear on your Desktop, but you should be able to access it much like any other folder using the Finder.
Using the .nsmbrc File

Instead of having to re-enter your password, username, and workgroup every time, there's actually a shortcut available to you. You can create a file in your home directory called .nsmbrc (note the dot). This file has a simple format that I'll explain below and allows you to store the information to save you time. One thing to note is that you should use the chmod command to change the permissions of the file to 0600 to protect your passwords. My ~/.nsmbrc file is below:



This file is very straightforward. First I'll explain the line in brackets. These represent [netbiosname:username:share]. So in the first example, I'm logging onto the WINBOX server as user JLDERA and trying to mount the JLDERA share (my home folder on Winbox). Below that, the first line is the actual IP address of Winbox. This field is optional, the address can be derived from the NetBIOS name. The next line is my password, and then the appropriate workgroup. Now when I mount a share using the Finder, it won't prompt me for this additional information, I can just enter the server and share in the Connect to Server dialog and I'm all set.

Paul Christl
HG Ad Designers

No comments: