This question already has an answer here:

I am executing following steps to mount my server and copy the files. But it interrupts for password. How can I do it automatic ?

sudo apt install cifs-utils 

sudo mount -t cifs -o user=user.name //192.168.X.X/BAfolder  /media

cp -r /media/BAfolder/* /home/techy/Documents/files/

marked as duplicate by Byte Commander, muru command-line Dec 23 '16 at 13:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • If it is for the cifs password, there is an option to mount.cifs -credentials=filename, where you may put username, password and windows domain name (see man mount.cifs) – ridgy Dec 23 '16 at 13:30

Save the password in a file with highly restricted permissions in a restricted folder that only you can access. Cat the file out and pipe the output to sudo -S instead of plain sudo.

cat <folder>/file.secret | sudo -S mount -t cifs -o user=user.name //  /media

store the password in a shell variable export password=X and then echo it

echo $password' | sudo -S mount -t cifs -o user=user.name // /media
  • hello, I mounted my smbfs witht he above command 'sudo mount -t cifs -o user=user.name // /media' But it is not executing on other system. I is showing me the options I can do with mount command. like man mount. What can be problem ? – techy Jan 2 '17 at 15:11
  • You run that same command on the other machine? Can you post a pastebin.org link to what you are seeing please? I believe you will want to open another post unless it is related to your original problem too. – Kyle H Jan 2 '17 at 15:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.