How to auto mount using sshfs?

You could create a launcher and add it to your launcher bar by drag&dropping the .desktop-file there:

    #!/usr/bin/env xdg-open

    [Desktop Entry]
    Version=1.0
    Type=Application
    Terminal=false
    Icon[en_US]=nautilus
    Name[en_US]=Connect to xy
    Exec=shfs [email protected]:/dir/dir /home/username/mount/xxx
    #OR: to mount and than open in nautilus (note the '/dir' where ':dir' used to be)
    #Exec=nautilus sftp://[email protected]/dir/dir
    Comment[en_US]=Connect to xy via ssh
    Name=Connect to xy
    Comment=Connect to xy via ssh
    Icon=nautilus

Suggestion - even less work:

If you want even less work (=autoconnect) and a graphical user interface, you might want to check out Gigolo Install gigolo. It has the capability of auto-mounting a bookmark, whenever the bookmarked filesystem is present. You might want to check that out.

sudo apt-get install gigolo   # or use the install link above

Run gigolo. There is an option in the preferences that puts it into autostart and another to activate the tray icon. Check both. Then add your bookmark.

Here is a screenshot:

enter image description here

Shell way

Another solution would be to put the following line in your crontab (edit /etc/crontab with sudo privileges):

@reboot sshfs [email protected]:/dir/dir /home/username/mount/xxx

But since Ubuntu's password manager is not present when the command is run you need to use a password-less private/public key pair to authenticate with the ssh server in question (or a similar method of authentication). This would mount it on every reboot.

Yet another solution would be to edit your /etc/fstab (providing your Ubuntu-Version provides that option).


This forum thread shows a method of creating an automounting SSHFS which seems to me exactly what you would like to do.


You can simply type this to a shell script, and you can create a launcher for it at the desktop.

For example mountssh.sh:

#!/bin/bash
shfs [email protected]:/dir/dir /home/username/mount/xxx

make sure to chmod +x mountssh.sh and then clicking it will execute

Alternatively, you can mount it via gvfs, by right clicking at the desktop, and creating a launcher with URL parameter: ssh://[email protected]/dir/dir. By default it mounts to ~/.gvfs/.... If you want stick with the /home/username/mount/xxx, you can create symlink from the gvfs one to this.

Tags:

Sshfs