Home > Mac administration, Mac OS X, Unix > Connecting to an SMB server from the command line in OS X

Connecting to an SMB server from the command line in OS X

I had a call yesterday, where someone was asking to SSH into a remote Mac workstation and mount a particular fileshare on that workstation. I had them do the following:

—–

1. Log into the Mac with your account login and password.

2. Create a folder inside your home folder named sharename to match the name of the share on the server

Note: You should only need to create this folder if it doesn’t already exist.

3. Use the following command to mount the share, using the new sharename directory as the mountpoint:

mount_smbfs //username@servername.example.com/share ~/sharename

4. You should be prompted for your account password.

5. The SMB share should mount and you should be able to access it via the sharename directory.

To unmount the server share from using the command line in OS X:

1. Log into the Mac with your account login and password.

2. Make sure you’re not in the ~/sharename directory.

3. Use the following command to unmount the sharename share from ~/sharename:

umount ~/sharename

—–

However, when mount_smbfs //username@servername.example.com/share ~/sharename was run, it didn’t connect and gave the following error:

mount_smbfs: server connection failed: No route to host

Trying mount_smbfs //username:password@servername/share ~/sharename also did not work. Same error, plus the user was understandably not happy with the idea of having his password in the clear.

After a bit more digging, I found the answer here. In 10.6, Apple had changed the mount_smbfs configuration so that it now expected the server’s workgroup or domain as part of the connection string. For anybody else that needs it, here’s how the command should be set up if the server is connected to an AD domain:

mount_smbfs //’DOMAIN;username’@servername.example.com/share ~/sharename

If you’re using a workgroup, it should be set up as:

mount_smbfs //’WORKGROUP;username’@servername.example.com/share ~/sharename

  1. Clayton
    July 11, 2013 at 5:53 pm

    Your information about correct syntax after 10.6 was gold! Thanks a lot!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 148 other followers

%d bloggers like this: