5

I'm trying to mount an SMB share on the terminal. I'm able do to that, if the server has no space in its name using this command:

$ mount -t smbfs //user:password@server/resource /Volumes/resource

However in my case the server name has a space and I can't figure out how to properly pass such a name.

I tried using double or single quotes:

$ mount -t smbfs "//user:password@ser ver/resource" /Volumes/resource
mount_smbfs: URL parsing failed, please correct the URL and try again: Invalid argument

I tried escaping the space:

$ mount -t smbfs //user:password@ser\ ver/resource /Volumes/resource
mount_smbfs: URL parsing failed, please correct the URL and try again: Invalid argument

I also tried using %20, \x20 and \040, but I get an error:

mount_smbfs: server connection failed: No route to host

I know I could use the IP address or rename the server, but that would be a workaround and not a solution and I'm wondering what I'm missing.

Jawap
  • 2,463
  • 3
  • 28
  • 46
  • can you add it in your `fstab`? – Atropo Apr 05 '13 at 16:22
  • How did you end up with a hostname with a space in it? As far as I understand this is not possible. – themel Apr 05 '13 at 16:23
  • @themel It's an AirPort Extreme with a HDD attached to it. When setting it up using the AirPort Utility, it didn't complain about the space in its name. Finder is also able to connect to the HDD, even with the space. – Jawap Apr 05 '13 at 16:27
  • Thank you for how to connect to samba, but please do not write the password to the bash, it will be save in your file history in clear. – Marco Sulla Oct 24 '14 at 14:12
  • 1
    The `%20` worked for me on macOS zsh, but it was in the resource name, not the server name. `mount -t smbfs //me:password@NAS/My%20Backups ~/My\ Backups`. Strange. – Joshua Pinter Feb 25 '21 at 04:43
  • See answers: [here](https://stackoverflow.com/questions/27026168/escape-special-characters-in-mount-command#answer-27027493), and [here](https://stackoverflow.com/questions/27026168/escape-special-characters-in-mount-command#answer-37179333) – Nick Korsakov May 22 '22 at 20:13

1 Answers1

1

What happens if you combine quotes and escape:

mount -t smbfs "//user:password@ser\ ver/resource" /Volumes/resource

That reportedly worked for someone when mounting an smbfs volume with a space in the username.

Bobulous
  • 12,967
  • 4
  • 37
  • 68