Facebook Twitter Instagram
    WiredRevolution.com
    • Home
    • About
    • Contact Us
    • Essential Linux Commands
    • Sitemap
    Facebook Twitter Instagram
    WiredRevolution.com
    system administration

    Share a remote filesystem over SSH

    RyanBy RyanMarch 25, 20093 Mins Read
    Facebook Twitter Pinterest LinkedIn Reddit WhatsApp Email

    You may already be familiar with NFS and Samba for sharing files over a network. While these are both great distributed filesystem solutions, they require extra configuration and setup overhead in order to get them to work. If you want quick and easy access to a remote filesystem then SSHFS may be your best shot.

    SSHFS (Secure SHell FileSystem) is a file system for Linux capable of operating on files on a remote computer using just a secure shell login. It is based on sftp (SSH File Transfer Protocol). Setup is easy on the server side, since most servers support SSH out of the box there is nothing to do. On the client side, mounting the filesystem is as easy as logging in with SSH. The end user can seamlessly and securely interact with remote files as if they were local to your machine.

    Advantages of SSHFS over NFS/Samba:

    • Utilizes SSH and is therefore very secure.
    • Allows secure access to remote filesystems outside of your local network.
    • Requires no special configuration on the server side.

    Disadvantages:

    • Slightly slower, although the difference is fairly small.
    • Does not show filesystem usage statistics.
    • Requires a user account on the server side.
    • Not a true distributed file system, single point to point sharing.

    Setup

    The first step is to install SSHFS.

    In Ubuntu:

    $ sudo apt-get install sshfs
    

    or in Gentoo:

    $ sudo emerge -av sshfs-fuse
    

    Create the mount point on your local machine. This is where you are going to access the remote filesystem.

    $ sudo mkdir /mnt/share
    

    Your user must have permission to access this mountpoint.

    $ sudo chown ryan /mnt/share
    

    Start Sharing

    Now use the sshfs command to mount the remote filesystem. If the username is different on the server you are connecting, use the “username@host:” format, otherwise you can simply specify “host:”.

    $ sshfs ryan@fileserver:/remote/share /mnt/share
    

    If you are not using keys with SSH you will be prompted for a password.

    ryan@fileserver's password:
    

    Once you are finished you can easily unmount the filesystem.

    as regular user:

    $ fusermount -u /mnt/share
    

    or as root:

    $ sudo umount /mnt/share
    

    Configuration

    You can add an entry for this share to /etc/fstab to make the mounting process more seamless.

    sshfs#ryan@fileserver:/remote/share /mnt/share fuse user,noauto 0 0
    

    user – allow any user to mount this share.
    noauto – stop the shared directory from being automatically mounted at startup.

    If you want it automatically mounted, ensure that your SSH configuration uses keys and not passwords so it doesn’t ask for a password at startup. Once keys are in use you can safely remove the noauto option.

    With fstab updated you can now mount the share as a normal user with this simple mount command. Again, if ssh is configured to use passwords you will still be prompted for one.

    $ mount /mnt/share
    
    Share. Facebook Twitter Pinterest LinkedIn WhatsApp Reddit Email
    Previous ArticleSetup NFS server on Gentoo
    Next Article Setup the PS3 Bluetooth Controller on Ubuntu

    Related Posts

    Fix insync Gnome Shell extension error on Ubuntu

    Netflix now working on Ubuntu Linux

    Transfer your ssh public key to a remote machine

    Most Commented
    March 12, 2009

    Fix blue tinted video in Ubuntu

    September 10, 2010

    Setup SSH access between VirtualBox Host and Guest VMs

    March 8, 2011

    Install GNOME Shell in Ubuntu 10.10 Maverick

    April 4, 2009

    Setup the PS3 Bluetooth Controller on Ubuntu

    October 22, 2008

    How to correctly use LD_LIBRARY_PATH

    Recent Comments
    • Execute command on linux virtual machine (or server) from windows commandline on Setup SSH access between VirtualBox Host and Guest VMs
    • Solved: How to SSH to a VirtualBox guest externally through a host? - Daily Developer Blog on Setup SSH access between VirtualBox Host and Guest VMs
    • How to SSH to a VirtualBox guest externally through a host? [closed] – Code D3 on Setup SSH access between VirtualBox Host and Guest VMs
    • How to copy and paste from VirtualBox? [duplicate] on Setup SSH access between VirtualBox Host and Guest VMs
    • Jackie Laguna on Fix OpenGL: ChoosePixelFormat SketchUp error in WINE
    © 2025 ThemeSphere. Designed by ThemeSphere.

    Type above and press Enter to search. Press Esc to cancel.