Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gvfs-mount specify username password

Tags:

ubuntu

Is there anyway to specify / pass a username password to gvfs-mount so that I can run it from a script without it waiting for the user to specify input?

like image 675
myforwik Avatar asked Aug 10 '11 04:08

myforwik


3 Answers

How about using a simple expect script? Something like this...you will need to change...just an outline

#!/usr/local/bin/expect --
set timeout -1
spawn gvfs-mount {args}
expect "User"
send "joe\n"
expect "Password:"
send "xxxxx\n"
like image 100
joemooney Avatar answered Nov 05 '22 07:11

joemooney


smb urls generally work along these lines:

smb://[[domain;]username[:password]@]server[/share[/path]]

I haven't tested gvfs-mount will accept the password like this but certainly it works for username and domain. gvfs-mount can just uses a stored password, if the user has stored one.

like image 44
mc0e Avatar answered Nov 05 '22 09:11

mc0e


This may be an older post but I didn't get it to work when I needed it recently. Now I have found a solution on the german Ubuntu Wiki. It works like a charm now.

Have a file with your login data, leave a blank line if you don't need e.g. the Domain (order as gvfs-mount asks for it):

username
domain
password

Then, in your script, simply call gvfs-mount smb://server/path < path/to/login/data, and here you go! I think you could also do it without a file, passing a string like that: echo 'username\ndomain\npassword' | gvfs-mount smb://server/path, but it didn't work when I tried. I don't know why, it suddenly didn't ask for a password or something...

like image 2
Peter Nerlich Avatar answered Nov 05 '22 07:11

Peter Nerlich