How to use password with special character in mount command linux ?

I faced a problem while using mount command with a password containing special characters. The error that I got was “permission denied”. On analyzing the root cause, I figured out that because of the special character, the authentication failed.

The syntax of the mount command is given below.

> mount -t cifs -o username= ,password=[password] [windows-share-dir-path] [dir-in-linux]

Here my password was something like below. It has so many special characters.

> i2_Gw$wF?Xs4zq??K


The solution is simple. Create a text file and enter the credentials into that file.

I have created a file with the name credentials.ini


Now save this file and use this credentials file in the mount command. The syntax is given below.

mount -t cifs -o credentials=credentials.ini [windows-share-dir-path] [dir-in-linux]


Now execute this command and your problem will be solved. !!!!