mounting smb share through terminal

Joined
Apr 14, 2011
Messages
1
Reaction score
0
Points
1
Hey all,

I'm trying to write a script that allows me to mount an SMB share.

So far I have got it working with this:

Code:
mkdir /smbaudit
mount -t smbfs //username:password@pathname/share /smbaudit

And this works assuming the computer is in the right domain. However I will be using this script on computers of a different domain so I will need to provide the domain name to the username

how do I provide the domain name? I tried:

Code:
mount -t smbfs //[B]domain\[/B]username:password@pathname/share /smbaudit

but it just gave me: mount_smbfs: server rejected the connection: Authentication error

I even tried to escape the backslash and instead I got mount_smbfs: URL parsing failed, please correct the URL and try again: Invalid argument
 
Joined
Dec 21, 2011
Messages
2
Reaction score
0
Points
1
Whenever you use a command line program and you're not sure about the right syntax, try using the man program to learn more.

man mount_smbfs is helpful here:
//[domain;][user[password]@] server[/share]
The mount_smbfs command will use server as the NetBIOS name of
remote computer, user as the remote user name and share as the
resource name on a remote server. Domain and/or password may be
specified here. If user is omitted the logged in user id will be
used. Omitting share is an error when mount_smbfs is run from
the command line, otherwise a browsing dialogue is presented.

So following that, you'd likely use:
Code:
mount -t smbfs "//domain;username:password@pathname/share" /smbaudit
The key being use of a semi-colon after the domain. Also note the use of quotes around the parameter. This helps make sure that any characters you use in the command shell don't get interpreted by the shell. This becomes important if you've got a password that has such characters.
 
Joined
Feb 6, 2012
Messages
5
Reaction score
0
Points
1
Any references as to how to debug an authentication issue when I can authenticate with the GUI (Finder) interface, but not the command line interface? :(
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top