Mount your home directory with SSHFS in Linux

If you have your home directory on another machine, it’s common to use NFS to access it. NFS is easy to setup and works more or less out of the box on Linux. However, NFS is not secure and you need to have a carefully setup firewall in order to use it safely.

SSHFS is a more secure alternative, but it’s quite tricky to setup on the client side. It’s very easy to setup on the server though, you just need an SSH server with SFTP support.

This is the way to setup it on the client using Ubuntu desktop 10.04:

  1. First you have to get rid of the file .ICEauthority from your home directory. Create a .gnomerc file in your home directory:
    mkdir "/tmp/.ICE-${USER}"
    export ICEAUTHORITY="/tmp/.ICE-${USER}/.ICEauthority"
  2. Then you need to setup a local bootstrap home directory containing this .gnomerc file and your .ssh directory including your private key file. The remote home directory will be mounted over this. This can be on a read-only filesystem. You need to modify your .ssh/config file to explicitly point out your private key and known hosts files, add this:

    IdentityFile /home/username/.ssh/identity
    IdentityFile /home/username/.ssh/id_rsa
    IdentityFile /home/username/.ssh/id_dsa
    UserKnownHostsFile /home/username/.ssh/known_hosts
  3. Setup mounting on login by adding this to /etc/gdm/PostLogin/Default:

    sshfs -F ${HOME}/.ssh/config -o nonempty -o allow_other -o default_permissions ${USER}@theserver: ${HOME}
  4. Setup umounting on logout by adding this to /etc/gdm/PostSession/Default

    fusermount -u -z ${HOME}
This entry was posted in Linux. Bookmark the permalink.

3 Responses to Mount your home directory with SSHFS in Linux

  1. Intressant! Ska testa så fort jag får chansen!


  2. j says:

    Very interesting! Will test as soon as I am presented with the opportunity!

  3. Pingback: Mounting A Network Dir Locally On Linux | Click & Find Answer !

Comments are closed.