Connecting to UCLA’s SEASnet servers using SSHFS

  1. Install a filesystem in userspace kernel extension
  2. Install SSHFS
  3. invoke sshfs <ssh-target>:<remote-folder> <mountpoint> [options]

<ssh-target> = something like
<remote-folder> = folder on the SEASnet server (/u/cs/ugrad/ari/)
<mountpoint> = your local mountpoint (~/Desktop/mnt)
[options] = whatever you want (-o auto_cache,reconnect,defer_permissions,volname=SEASnet)

The long version

Recently, there was a question asked in the UCLA CS Facebook group by Hakan Kimeiga that interested me. You can see it here:

You mean typing out `scp -r /Users/ari/Downloads/` in my terminal every time I wanna have a file locally isn’t the best workflow!?

There were a lotta interesting comments on the post, you can check out the full post, comments and all, here.

But one really interested me, from Cody Ley Han:

Whoa, that’s way better than what I was doing.

!! Mounting the SEASnet files directly to my computer means that I’d be able to edit my SEASnet OCaml files using all the pretty syntax highlighting that sublime supplies! I need that. I NEED that.

There were a few steps that I needed to go through in order to make this happen.

First, I had to download a kernel extension that allowed me to have file systems in user space (you don’t have to worry about what this means until after you take CS 111).

  • Linux: FUSE
  • Windows: Dokan (there’s more options for Windows, if you care)
Yes, OSXFUSE ❤️, you’ve made File System integration so easy for me :’)

Now that I had a FUSE API, (which lets developers play around with file system APIs), I could download and use SSHFS. (a program that plays around with file systems)… Nice!! With fresh installs of OSXFUSE and SSHFS, I was ready to mount the SEASnet server’s files to my computer.

Basically, mounting file (foo.img) from a physical disk to a file (/mnt/foo) on your computer says: “Read the bytes at this file (foo.img), and interpret them as a specific data structure. Display the information we’ve gathered from these bytes at (/mnt/foo).”

a file system is just a large and meticulous data structure

File systems are cool! Maybe check out these pictures to help give you a lil idea of what a file system might be: 1, 2, 3. Don’t worry, you’ll learn all about these bad boys in CS 111.

  1. Aside: If you type mount into your shell, then you’ll see a list of all the disks you’ve mounted. If your computer has any storage, then you’ll have at least one disk mounted.
  2. Aside: You can mount both physical devices, and virtual devices. Virtual devices? I meant disk images. Disk images? I meant files that’re made up of binary data, structured corresponding to a file system. (.img or .dmg)
  3. Aside: SSHFS actually mounts a remote-ssh’able-folder instead of a file. But you can bet that it packages everything up in a nice little data structure to send over the network

Anyway, back to actually mounting the file system! Now that I had all the power and capability to connect, I needed to figure out exactly what I wanted. I didn’t wanna mount /from the SEASnet servers, because then I’d have to click through all those folders to get to my files. I wanted to mount the virtual disk /u/cs/ugrad/ari/Classes. Y’all will wanna mount something else.

And I wanted to mount those files to somewhere that I could open easily – I wanted my mountpoint easily accessible. I made the folder ~/Desktop/mnt for this purpose.

Notice how my mountpoint no longer shows up as a folder named ~/Desktop/mnt! Finder now displays it as a disk named ~/Desktop/lnxsrv. Kinda weird, right?

Probably don’t mount directly to your Desktop, or else you’ll hide all of your Desktop’s files whilst the SEASnet server is still mounted. And that’ll look really strange. It’s okay, though, because you can undo your mistake by just unmounting the disk that you mounted to your desktop. One of many ways to unmount a disk is by using the umount command. umount <mountpoint> or umount <host>:<remote-folder> both work. Remember, you can figure out your disk’s mountpoint by using the mount command.

If you don’t wanna use a CLI to unmount, then you can just right click a mountpoint and click “eject”. You can even just drag it to the trash in macOS. Neat!

And boom! We can access remote SEASnet files as if they were stored directly on a folder on my desktop. The options I used to mount my server are:

-o auto_cache,reconnect,defer_permissions,noappledouble,volname=lnxsrv

You can find what each of those tags do by reading the sshfs man page.

It works, and it’s so easy, too!

The script below is the simplest version that worked.

#!/bin/bash#mt-lnxsrv – a script that helps me mount over sshfsHOST="ucla"
FLAGS="-o auto_cache,reconnect,defer_permissions,noappledouble,volname=lnxsrv"
#get the script `connected` from my github, or omit this line
if ! connected; then echo "bad"; fi
printf "\tMounting"
printf "\tDone!\n"

Go to my GitHub for the actual scripts and aliases I use to make mounting easy. My newer scripts are a lot better 😁

I hope you enjoyed the read! I want to get better at writing technical guides. If the pacing was off, or something else was bad, please tell me how I can improve.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Seventeen Basic Techniques from my Code Review Checklist

45 useful mobile apps that I use as a developer

Information gathering from instagram accounts

Layer Your Clothes: How Canadians Keep From Freezing Their Junk Off on Winter Adventures

Floating Point Round Problems

YMDK Split 75% Keyboard Build Log— Successes and Mistakes

OFAC Checker: Automated OFAC list screening app

Tutorial: How to Scale and Rotate Contours in OpenCV using Python

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store

Ari Sweedler

More from Medium

Install PhpMyadmin Ubuntu 20.04 Apache2

How to run 32-bit app on 64-bit Linux distros

[Vulnhub] LazySysAdmin Write-Up

Send Email With Postfix via Gmail