In a previous post, I’ve shown how to use SSHFS to mount a remote directory as a volume in Mac OS X. Of course the same can be done to connect two Linux boxes.
Here’s a short description how to do it on Debian.
First you’ll need to install sshfs using apt-get:
apt-get install sshfs
Note that this will also install fuse as a dependency.
Then you need to have a public key authentication in place. I’m assuming that ssh is already installed on the server. You now should do the following, on the Linux box where the file system should be mounted:
apt-get install openssh-client
Now you can generate a key:
mkdir ~/.ssh chmod 700 ~/.ssh cd ~/.ssh ssh-keygen -t rsa -C "firstname.lastname@example.org"
Of course replace my email address by yours. You can then print the key:
This should be added to the file ~/.ssh/authorized_keys on the server.
You also need to make sure that PubkeyAuthentication is set to yes in /etc/ssh/sshd_config so that public key authentication is supported at all.
Now you can connect using ssh without password and can mount over ssh:
mkdir ~/amazingweb sshfs -p 22 USER@xxx.xxx.xxx.xxx:/var/www/vhosts ~/amazingweb -oauto_cache,reconnect
Replace USER by the user for which you’ve setup the public key authentication.
Replace xxx.xxx.xxx.xxx by the IP address of the remote server.
Replace ~/amazingweb by the path where you want to mount the remote file system.
It’s basically the same command as under Mac OS X except that you have to remove the 3 following options which are not available under Debian: