2

I am trying to mount a share with the macOS CLI using zsh as my shell.

mount -t smbfs //user:password@host/share /share

Mounting the share without specifying the password works. But then I have to enter the password manually. As soon as I pass the password via the command line, I get an error message. I have a very strong password with many special characters, such as .()[]{}<>*=.

mount_smbfs: URL parsing failed, please correct the URL and try again: Invalid argument
mount: /share failed with 64

Placing the password in single or double quotes does not solve the problem. I assume that I have to enter the password without quotes and escape some of these special characters. Where can I find a list of characters that have to be escaped in passwords (or cannot be used at all)?

6
  • Which shell are you using for your command line mount?
    – bmike
    Jun 9, 2022 at 8:20
  • I found stackoverflow.com/questions/27026168/…
    – Tetsujin
    Jun 9, 2022 at 8:23
  • Also stackoverflow.com/a/38199336/475228 leads to dumping the credentials in a file to avoid shell / URL encoding issues - serverfault.com/q/309429 which for the Mac idiom would be to store it in the keychain and access via security to really complicate things…
    – bmike
    Jun 9, 2022 at 8:24
  • I am using the Z shell.
    – Chris
    Jun 9, 2022 at 8:27
  • The links are very helpful. But is there somewhere a list of character that must be escaped?
    – Chris
    Jun 9, 2022 at 8:29

2 Answers 2

1

I finally solved the problem differently. I changed to SSH key-based authentication, which is probably even safer than a long password with many special characters.

1
  • Very nice practical solution.
    – bmike
    Jun 9, 2022 at 11:40
0

Apple programs this into swift for which characters are allowed in the password field for a URL. Not entirely sure if this helps for the smbfs mount but it’s what I would use to have swift encode my password if I were passing it as you do in the command.

To implement this in code, you could use swift, php or python and these links covering specific of doing the url encoding and seeing if that alone help with escaping and quoting.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .