Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Commas inside the password while using "mount"

Tags:

linux

mount

samba

Need to mount a specific directory from Windows to Linux:

mount -t cifs -o username=somebody password=12,34 //192.168.1.3/share /mnt/server

Notice that there is a comma inside the password, and that makes Shell mistake it as a separator.

How to deal with that situation?

Thanks!

like image 565
JeremyQiu Avatar asked Dec 05 '25 21:12

JeremyQiu


1 Answers

Description of password option in man mount.cifs explicitely says, that you cannot use comma-contained password in command line:

Note that a password which contains the delimiter character (i.e. a comma ',') will fail to be parsed correctly on the command line. However, the same password defined in the PASSWD environment variable or via a credentials file (see below) or entered at the password prompt will be read correctly.

You may set PASSWD variable within same line as mount:

PASSWD=12,34 mount -t cifs -o username=somebody //192.168.1.3/share /mnt/server

Alternatively you may use credentials file, as described in this manual.


BTW, it is not shell who incorrectly interprets comma. Actually, username and password are both suboptions for -o option, and these suboptions should be delimited by comma for being correctly parsed by the program(mount) itself:

mount -t cifs -o username=<username>,password=<password> ...

And such suboption mechanism have no means to parse comma inside suboption's value.

like image 193
Tsyvarev Avatar answered Dec 08 '25 13:12

Tsyvarev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!