How to Mount Password Protected Windows Share Without Sudo in Shell Script?

How to Mount Password Protected Windows Share Without Sudo in Shell Script?

In order to pass a password in a shell script you will have to write:

sudo mount -t cifs -o password=asdasd,username=mc007,uid=1000 //192.168.1.105/cfmaster/ /PMaster/projects/x4mm/win

But there are situations you don't want to use sudo (build-scripts,...).

And so if you don't use sudo, the command will abort with:

only root can use "--options" option

Now, how can one mount network share with password from within a non-interrupting shell script?

thanks

10

1 Answer

As mentioned in the comments, user 'muru' suggests to look at How do I run specific sudo commands without a password?. After researching it seems the only official supported way to mount a password protected windows share from within a script.

It needs you to be a tech savy, and it needs you to alter system files with root permissions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.