Mount remote share at login on Ubuntu Linux using gvfs-mount

In this article I'm going to show you how to mount remote shares at login as regular user Ubuntu Linux using gvfs-mount. To mount shares at boot (as root user) you would normally edit fstab, but to automatically mount shares as regular user with your shares password inside Gnome keyring you would use gvfs-mount. I will also show you how to make sure that your share password is stored inside "login" keyring so your share could be mounted at login without requiring you to enter any password.

Before setting our shares to be mounted at boot we will make sure that our keyring stores password necessary to access that remote share. Take note the way to store passwords into keyring my differ based on the type of service. To be sure that your service password is in the keyring you can manually connect to your service once by saving password when Ubuntu asks you. After that connecting to that remote share will also work at login. If you are trying to mount remote share that doesn't require password like anonymous FTP you can skip this section. This is how you would manually store password into keyring for authenticated FTP remote share:

First you open terminal and type following to start Gnome password passwords and encryption key manager:

seahorse

Ubuntu have probably asked you when you first started using key manager do you want to store password for "login" keyring or use unsafe storage. If you have entered "login" keyring password but later changed your mind in a way that you don't want to enter keyring password to unlock keyring at every login, you can now right click on "login" entry and click "Change password". Then you will change your "login" keyring password to blank, if not your share will be mounted at login just after you unlock your "login" keyring by entering your "login" keyring password when prompted.

Now click on File -> New and select "Stored password" like in the following screenshot:

Manage your passwords and encryption keys 2

Now you just select "login" keyring from the drop down menu, enter your FTP service login name and service identifier and you're good to go. Again if you are connecting to service other than FTP you should let Ubuntu add your password to the "login" keyring by connecting to that remote share at least once using Nautilus and selecting to save password when prompted.

Manage your passwords and encryption keys 3

Now that you've got your keyring in order here's how to mount your shares at login as regular user (no need to use sudo):

gvfs-mount 'user@service.com'

Be aware that this command will connect you to FTP service and that you might need to change it based on service you are accessing. For example to access Samba share you will ommit user@ part of the command and use it like gvfs-mount 'smb://service/folder/'.

To set your gvfs-mount command to be started at login you will add it at the end of your .profile file inside your home directory like this:

echo "gvfs-mount 'user@service.com'" | tee -a /home/$USER/.profile

That's it. Next time you login your remote share will be mounted and ready for use.

DevGenii

E-commerce is a breeze with Magento Certified Developer Plus & Zend Certified PHP Engineer nearby. Get in touch!

One thought on “Mount remote share at login on Ubuntu Linux using gvfs-mount

Leave a Reply

Your email address will not be published. Required fields are marked *