Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Ten different ways to connect to servers Network
Watching someone else working on his Mac (especially in a bigger network environment with many servers) showed me that not everyone seems to know that there are different types of servers, and different ways to mount them in Finder. And not everyone really uses the best way -- although there is never the best way and everyone has to find his/her way for the best workflow handling. But did you know all the following ways of mounting a server?

Read the rest of the hint for 10 different ways to mount a server share....

  1. The browser way
    Maybe you can find the server of your choice directly on the Finder sidebar, or you have to click on All on the Finder sidebar and then scroll through the server list. Double-click on a server and you will see the shared folders provided for guests, or someone with your username and password. Click on 'Connect as...' to authenticate with a special username and password.

    This way may be the best way to access servers for a sporadical need. But for a daily need, access is too many clicks away, and maybe for every different server, a special authentication is needed.

  2. The alias way
    Mostly used: Make an alias of a mounted server (however it was mounted the first time) and place it directly in the dock, if you want a large cluttered Dock. Alternatively, if the Finder preference Show Connected Servers on Desktop is unchecked), place it on your Desktop. Finally, if you like order, place it in a folder with a groovy icon that's located somewhere on the hard disk and placed in the Dock.

  3. The dialog box way
    For a once-and-never-again server this is a fast way, but for daily use, very ugly: The Finder's Go >> Connect to Server dialog box, where you have to enter the name or IP adress of the server you want to connect to. You can create some bookmarks with the "+" button, and view the last connected servers in the History menu, but for often-used servers, I would call this method ugly.

    Hint: Some people may not know that you can manually choose the file protocol in this dialog box. If you just enter the server name or IP adress, Finder tries to connect via AFP (Apple File Protocol). You can also add the prefix afp:// with the same result. Other possible prefixes are smb:// or cifs:// for Samba (commonly used for Windows environments), ftp:// (for read-only access to FTP servers) and http:// for WebDAV.

    So I use this dialog box sometimes to make an SMB connection to a server I normally connect to via AFP (as SMB may provide other shared folders, or maybe I want to do a test).

  4. The Scripter's way
    Why a script? You can add the script to a helper application like Butler or Quicksilver, and your servers are just one click or keystroke away. You can write a one-liner AppleScript to connect to a server:

    tell app "Finder" to open location "protocol://username:password@server/share"

    Some examples:
    tell app "Finder" to open location "afp://admin:admin@macmini.local/music"
    tell app "Finder" to open location "smb://admin:admin@"
    tell app "Finder" to open location "afp://;AUTH=NO%20USER%20AUTHENT@macmini.local/music"
    The last line looks weird, I know: For AFP you can also use the string ;AUTH=NO%20USER%20AUTHENT instead of username:password -- it's the same as clicking on Guest access when authenticating to a server.

  5. There are bookmarks, you must know...
    Open a new TextEdit document, change to unformatted text mode via the Format menu, and enter a connection string with the same scheme shown in the Scripter's Way (but without the scripting code, of course):


    Now select this line and drag-and-drop it onto your Desktop. You should get a new file with a bookmark icon. If it's just a text clipping icon, the syntax of your connection string was incorrect.

    You can rename this bookmark to something clear and short, place it somewhere in a nice place (for example, a folder called Servers with a nice icon in my home directory that's placed in the Dock and set to Show as Folder, Show as List), and all your commonly-used servers are once again one click away. This is my preferred way -- I'm handling about 30 servers this way in my company.

  6. Automation is all
    Of course, you can drag an already-mounted server to the Login Items tab of the Accounts System Preferences panel. It will then automatically mount the next time you login. You can also drag the bookmark from method #5, an executable script from #4, or an alias from #2 there.

  7. Mount-as-you-type
    Not very common for local servers, but possible: Type protocol://user:password@server/share in the Safari location bar, and it will mount in Finder.

  8. The Unix Admin way
    If you didn't know this yet, as of Mac OS X 10.5 and later, autofs is implemented. Maybe you'll shout "wow" or "I already knew that", or maybe not. Anyway, let's consider one scenario: One folder in /Users/Shared (so that all users can access the servers) containing some servers you often use. You can drag this folder to the Dock for easy access. Then open a new Terminal session. First we'll create a file containing all necessary server links in the /etc directory; let's call it auto_mount: sudo pico /etc/auto_mount.

    In this file, enter an arbitrary name for the server (please do not use blank spaces and special characters), followed by protocol and connection details. Some examples for different protocols:
    Pictures -fstype=smbfs :/admin:admin123@
    Music -fstype=afp afp://admin:admin123@
    Save the file when done, and open the autofs master file: sudo pico /etc/auto_master. Append one line at the end containing the name of our newly-created file, and the name of the folder where you want to make the server connections appear:
    /Users/shared/servers auto_mount
    Don't forget to create the folder /Users/shared/servers if it doesn't exist. Now just reload autofs: sudo automount -cv. Note that the passwords for servers that you've entered in the auto_mount file are readable by everyone that can access the computer. But I guess it's no big security issue, because everyone using the machine should access the servers, so everyone should know the password.

    We should have a folder servers in the shared users directory with a server alias icon containing all the auto_mount defined server shares in form of a blank document alias icon. Double-clicking shows the contents of the server with the side-effect that it will not show up on your Desktop as a mounted server (even if you have checked the Finder preference "Show Servers on Desktop").

    Why did I tell this? This way may be a good way for some environments with many users. Imagine: You just have to create the folder in the shared users directory (or somewhere else) and maybe drag it to the Dock. Then you have to create the the auto_mount file and edit the auto_master file. After that, if the servers in your infrastructure change, you just have to edit the auto_mount file of every client machine via ssh -- or copy a new one via scp to every client, and you're done.

  9. The geek way
    Of course, Unix can do what a GUI can do (and even more), so there's a method to mount servers via Unix shell. But I'm not sure if this way is really useful if you're not writing shell scripts that have to access servers. But to complete my article, here's the way to mount a server via bash in Terminal:

    First we have to create a directory -- the mountpoint -- where the contents of the mounted server will appear. This directory can be anywhere on your hard disk; for a better tidiness I would recommend a folder with the name of the server share in a folder called mnt at the root directory. For example:
    $ mkdir /mnt
    $ mkdir /mnt/music
    $ mkdir /mnt/movie
    The mount command should be more or less familar:
    mount_smbfs //admin:stevie123@macmediaserver.local/itunesmusic /mnt/music ## for SMB shares ##
    mount_afp afp://admin:stevie123@macmediaserver.local/mymovies /mnt/movie ## for AFP shares ##
    When cding to the directory specified as the mount point, you should see the contents of the server share.

    On the Finder side: After executing the script, the folder /mnt/music gets a server-alias-icon, and when double-clicking, it shows the content of the server -- and the server also mounts on the Desktop as if it was mounted in the ordinary way. When ejecting, the server disk disappers and the mount point folder gets its old folder icon back.

    Keep the unix slogan "think before you type" in mind. If the folder /mnt/music contains any files before the mount command, they will disappear after the mount command (but will come back after unmounting). When removing objects via the command line before the mount command (rm /mnt/music/*) will remove any file within the folder -- but it will remove any file on the server when executed after mounting!

    By the way, you can unmount any server via command line with the umount command followed by the mountpoint path: umount /mnt/music

  10. I want more
    Of course, there are many applications that can handle servers for you. You have the choice between freeware, shareware, and commercial software; and menu bar, Dock, and/or Dashboard-integration. If the first nine methods weren't good enough for you, or software with a special intelligence like "mount this server if my home network is in range" is needed, there's a solution out there somewhere.
[robg adds: I haven't personally tested every one of these methods, but I've used many of them. Note that I modified method #8 to refer to the /etc directory -- I'm not positive you need to store the auto_mount file you create must live there, but it's definitely where you have to edit auto_master.]
  • Currently 3.39 / 5
  You rated: 1 / 5 (28 votes cast)

Ten different ways to connect to servers | 20 comments | Create New Account
Click here to return to the 'Ten different ways to connect to servers' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Ten different ways to connect to servers
Authored by: psonice on Apr 06, '10 07:59:02AM

You missed a really good one!

In finder, simply drag the server/folder/whatever icon to finder's toolbar. It creates a shortcut that works as a standard toolbar button.

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: mankoff on Apr 06, '10 08:21:08AM

Don't forget sshfs / MacFUSE.


[ Reply to This | # ]
Variation on the alias method
Authored by: hamarkus on Apr 06, '10 09:14:51AM

I know this falls under alias but I find it much more palatable to have a couple of servers in the Finder sidebar than in the Dock or on the Desktop. Most of the time you need access to a server is when you are in the Finder (or in a open dialogue which also shows the Finder sidebar).
There is one caveat though, you cannot drag a server (or a server share) into the sidebar, only folders from that share. Thus, just drag a commonly used top-level folder into the sidebar instead.

[ Reply to This | # ]
Variation on the alias method
Authored by: BiL Castine on Apr 07, '10 05:44:00AM

Actually, you can drag a share to the top of the sidebar with the other volumes, but it's only visible when the share is mounted via another method (see this hint). I have 9 different shares that only show up when they are mounted (in my case, via an alias in a folder on the dock) and have a nice little eject icon next to each of them.

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: daGrimm on Apr 06, '10 09:30:54AM

Just wondering: is there an advantage of #5 over #2? I thought having an alias to the server should do the same, but wasn't too sure. Would be great if someone knew & posted - thanks!

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: asmeurer on Apr 06, '10 06:25:24PM

Doesn't #5 save the password for you (although if #2 will save it in the keychain that will be better because it will be encrypted)?

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: emale on Apr 07, '10 10:50:48AM

#5 is better when distributing the bookmarks to different clients (if the passwords for the serveraccess are the same, of course).
Although I'm not a big fan of this "black box" aliases that may break from time to time (had that some times in my company. Maybe because of some changes at the server or client) - in the bookmarks all connection info is readable and editable when dragging the bookmark to a text document.

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: fds on Apr 06, '10 09:55:19AM
I think the more commonly used way in AppleScript is
mount volume "afp://user@machine._afpovertcp._tcp.local/share"

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: vtlucks on Apr 06, '10 09:59:30AM

You can also use the Automator and the "Connect to Servers" action.

I hadn't know about bookmarks (#5). I just set up a bunch of shares using that method and I really like it. I didn't have to specify the username and password because they were already in my keychain.

One problem I've found with all these methods is that when you show "Connected servers" on your desktop, the name is always the share name. I have 8 WinXP machines that were all set up by the vendor with the same share name (different IP addresses). It would be great if I could control the name that gets displayed on the desktop.

[ Reply to This | # ]
Re: #9
Authored by: bcamp1973 on Apr 06, '10 10:06:10AM
I just played around with option #9 and had to change the syntax a little to get it to work. This is what worked for me...
mount -t smbfs //username:password@server/path ~/Desktop/mount_point

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: daveywest on Apr 06, '10 10:42:17AM

#3 The dialog box way also allows you to use "vnc://..." to establish remote screen sharing connections.

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: zpjet on Apr 06, '10 11:03:31AM

Another protocol you could use in Cmd-K dialogue or as a bookmark is vnc: for connecting via Screen Sharing. And another is ssh: which opens Terminal. I guess there's more...

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: esbenab on Apr 06, '10 12:36:47PM
In a terminal window use the open afp://user@machine._afpovertcp._tcp.local/share command, should work with all finder mountable protocols.

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: smc13 on Apr 06, '10 04:22:53PM

If we are talking about just connecting to another server, the most common method on a Unix system is to ssh to it. As far as mounting a remote server to use locally, wouldn't the standard Unix method be to use NFS and not smb or afp?

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: rhowell on Apr 06, '10 08:53:33PM

Disk Utility->File->NFS Mounts...

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: nwfrg on Apr 08, '10 09:19:43AM
Other NFS Mounting Tips:
  1. Sept 2009
  2. Dec 2007

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: jamietshaw on Apr 08, '10 02:18:10PM
Very useful. There is yet another way: run scripts with launchd. Our music is stored on a server and I wanted to do the following things:
  • Automatically connect to the server upon login without a Finder window appearing (as happens with System Preferences > Accounts > Login Items), and without using a third party program
  • Check server connection when iTunes is started, and connect if necessary
  • Check and connect every few minutes while iTunes is running
By using two launchd items and two scripts, this is possible. First, the launchd items. Lingon can be used to set these up with a GUI, otherwise create a text file with content such as:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
		<string>/Users/barry/Music/iTunes Library Extras.itdb</string>

Save in ~/Library/LaunchAgents if specific to a user or /Library/LaunchAgents to run for all users. This 'agent' runs when someone logs in and when the /Users/barry/Music/iTunes Library Extras.itdb is modified - which generally only happens when iTunes starts up. It doesn't seem possible to monitor the main iTunes Library database, perhaps because of its lack of filename. The agent expects to run a shell script /Users/Shared/; this will actually do the connecting and will be written later.

One further launchd agent can be created to run every few minutes. In the example below, it runs a script called /Users/Shared/ every 60 seconds:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Now, to create the scripts. does the connecting to the server. In this example, it actually mounts two sharepoints with SMB. It also contains commands for AFP connections, commented out.


# Program to connect to two sharepoints on a remote server.
# Make sure this script is executable by root.

# Problems: password is hard-coded into this script. No access should
# be given to this script except to admins and root.

PROGNAME="Connect to NAS (barry)"

# IP address or name of server

USERNAME="`whoami`"  # Use "`whoami`" if OS X short username is same as username on server.

# No. of secs to stop checking for the IP address
# Give time for server to awake from sleep.

# First connection: where to mount locally
VOL1="/Volumes/DS Shared"

# First connection: name of remote sharepoint, with spaces converted to %20 etc.
# To see which special characters need converting, connect with Finder's Go > Connect to Server
# and once connected, do Get Info on the server to see the name.

# Second connections

# =======================================================================

# Check server actually exists before trying to connect
/sbin/ping -c 1 -t $TIMEOUT $IP &>/dev/null
if [ $? -ne 0 ]; then
	syslog -s -l Error "$PROGNAME: Cannot connect to server $IP"
	if [ -d "$VOL1" ]; then
		syslog -s -l Error "$PROGNAME: $VOL1 already exists. Not trying to mount it."
		mkdir "$VOL1"
		chown $USERNAME "$VOL1"
		chmod 777 "$VOL1"
		syslog -s -l Warning "$PROGNAME: Connecting to NAS for $VOL1"

		# Fortunately sudo isn't required, because it logs commands (incl. the password) in the Console.
		#/sbin/mount -t afp -a -o nodev,nosuid "afp://$USERNAME:$PWD@$IP/$SHARE1" "$VOL1"
		/sbin/mount -t smbfs -o noatime,nodev,nosuid,-d=0777,-f=0777 "//$USERNAME:$PWD@$IP/$SHARE1" "$VOL1"
	if [ -d "$VOL2" ]; then
		syslog -s -l Error "$PROGNAME: $VOL2 already exists. Not trying to mount it."
		mkdir "$VOL2"
		chown $USERNAME "$VOL2"
		chmod 777 "$VOL2"
		syslog -s -l Warning "$PROGNAME: Connecting to NAS for $VOL2"

		#/sbin/mount -t afp -a -o nodev,nosuid "afp://$USERNAME:$PWD@$IP/$SHARE2" "$VOL2"
		/sbin/mount -t smbfs -o noatime,nodev,nosuid,-d=0777,-f=0777 "//$USERNAME:$PWD@$IP/$SHARE2" "$VOL2"

The final script is the one that runs every few minutes, It checks to see if iTunes is running, and if so runs the other connect script. If iTunes is not running it does nothing, meaning that the server doesn't get woken up from sleep unnecessarily.


# See if iTunes is running. If so, check the server is connected and connect if needed.
# Could be run every few mins from launchd.

# Assumes that iTunes is called iTunes, but doesn't have to be in the Applications folder.
# Can't just search for 'iTunes' in the process list, because 'iTunesHelper' is always running.
ITUNES_PROCESS_COUNT=`ps -A -o comm | grep --count ""`

if [ $ITUNES_PROCESS_COUNT -gt 0 ]; then
   `dirname $0`/

I made these scripts accessible only to root with chmod 700 etc.

NB In addition, I made the ~/Music/iTunes Media/Music folder an alias to the actual location of the music and locked it. iTunes has an annoying habit of defaulting back to this location if the proper location isnít available.

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: prnl on Oct 18, '10 07:46:37AM
dscl localhost -ls /Search/NFS
Lists NFS mounts specified in Disk Utility.

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: sbsyncro on Jul 24, '12 08:33:24AM

I've diddled with many of these methods to reliably connect to the 4 volumes I have on my Synology NAS (Time Machine, Photos, Documents, Video, & Music). I finally settled on an automator app that I launch at startup because it seems the most flexible. One thing I'm still trying to figure out, though is how to place an automator action sequence that tests for the availability of the volumes and exits the app if they are not available. (e.g. I am away from home). Any ideas?

[ Reply to This | # ]
Ten different ways to connect to servers
Authored by: Mike G on Jun 24, '13 01:01:34PM

Is there a way to test a path on a Mac? If I paste the path in a PC window, and click return, it takes me to that folder!
It does not work on a Mac, even if:
I change the direction of the slashes..
I paste it into Connect to Server...

I'm writting some code, the path is part of that code; I'd like to verify the path is correctly written. Any ideas?

[ Reply to This | # ]