Mounting a remote drive locally
You may find it convenient to âmountâ a remote drive (like your /sciclone/home/<user>
directory) on your local, personal computer. This means you add the directory to your local file system in a way that looks just like a local directory to your computer and all the apps on it. Once you do this, you can open your remote folder in your Files/File Explorer/Finder app just like any other folder, move files around, etc â you can even open scripts on the remote machine in a coding IDE on your local computer, without any plugins/SSH necessary!
Letâs learn how to do this. It is easy on Linux, and fairly easy on Mac and Windows. Instructions for Windows are not included here (if you have done it, send a PR to this repo and weâll add it!)
Mounting on Linux
For Linux, weâll use the sshfs
utility (âSSH Filesystemâ). First, make sure itâs installed:
sudo apt update
sudo apt install sshfs
Then create a directory where the remote directory will be mounted, for example:
cd ~
mkdir mounts
cd mounts
mkdir sciclone
Now, use sshfs
to mount the remote directory. Here weâll mount our home directory on SciClone (this uses the shorthand bora
because weâre assuming youâve already setup your SSH config file, if not youâll need to use the full <user>@bora.sciclone.wm.edu
):
sshfs bora:/sciclone/home/<your-user-name> ~/mounts/sciclone
If successful, it will return silently (no output) and you can try:
cd ~/mounts/sciclone
You should see your folders. Note that your symlinked folders like data10
or scr*
will appear here, but are inaccessible â those live on a different machine on SciClone and require their own mount.
Try making a file with touch test.txt
. Now SSH directly into the remote server and youâll see the file is there. You should be able to open it and edit, in both places. (This is because while working in the folder via SSHFS, you inherit your remote UID through the SSH actions happening under the hood. It would be inconvenient if you were your local computerâs UID when on the remote directory!)
To unmount the drive, you just do
umount ~/mounts/sciclone
Re-connection options
If you restart your computer, it will disconnect this mount and youâll still see your ~/mounts/sciclone
directory but itâll be empty. It is probably best practice to manually re-mount the drive each time, especially for example, a desktop with a hard-wired connection.
Sometimes, when the computer goes to sleep, it disconnects, so you may try adding the flag -o reconnect
to your sshfs
command.
Also if you prefer, instead of manually reconnecting on startup every time, there are several ways to do this automatically on startup, that we will not cover in detail here but you can look up:
- Add a line to your
/etc/fstab
file (âfilesystems tableâ) which tells Linux how to mount drives on startup. - Create a bash script
mount.sh
with the sshfs command and then configure Linux to run this script on startup (âStartup Applicationsâ) - Use
systemd
to manage the mount (this is the most robust solution) but also most involved.
Mounting on Mac
Mac doesnât have native SSHFS support, so we need to use the third-party macFUSE
(formerly OSXFUSE) utility. You can install it with Homebrew (brew install macfuse
), or directly from their website. (Use the âmacFUSEâ download, not the âSSHFSâ download.) MacFUSE allows you to use non-Mac filesystems, on a Mac â for example, SSHFS.
Once youâve installed macFUSE, you need to also install SSHFS (brew install sshfs
). (If you donât have Homebrew, you can follow these instructions. It is possible to build/install sshfs without brew but itâs much more complicated.)
Now you can use the same commands as Linux (see above), knowing that macFUSE is doing some middle-man work under the hood to let the remote FS play nice with your Macâs.
Mounting on Windows
On Windows, you need tools like WinFsp and SSHFS-Win. This section is pending someoneâs input who uses Windows â come be a contributor. :)