# Ubuntu – How to specify a password when mounting a smb share with gio

cifsmountpermissions

I'm working on a software that needs to mount a smb/cifs share automatically.

The catch is that the share must be mounted using the user's login and password, and, AFAIK and for reasons completly unknown to me, looks like gio doesn't have an option to specify the password in the command line, only the user. If the user requires a password, it asks for it interactively. While this works for someone calling gio from the terminal, for a development… it's a pain.

gio mount smb://<user>:<password>@<server>/<share>/


but it just ignores the password and asks for it in the terminal. The (poor) documentation does not show any way to specify the password. Is waiting the password prompt and "emulating" an input the only way to set it?

Using mount -t cifs is not an option, since it requires root/sudo, and the
software I'm working on isn't supposed to require elevated privileges.

Create a file in your home directory. For example at /home/morbius/.servercreds

Into that file enter your credentials. You must specify the user name, workgroup, and password - one per line

<username>
<workgroup>

gio mount smb://<server>/<share> < /home/morbius/.servercreds