Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save malcolmgreaves/d8c57edbb99a2aa82e73cc19d28b7fb9 to your computer and use it in GitHub Desktop.
Save malcolmgreaves/d8c57edbb99a2aa82e73cc19d28b7fb9 to your computer and use it in GitHub Desktop.
How to mount a GCP compute instance filesystem locally using `sshfs` on MacOS

How to mount a GCP compute instance filesystem locally using sshfs

This guide assumes that:

  • you already have an instance set up on GCP that you want to mount locally
  • the GCP CLI (gcloud) is installed on your local machine
  • you have authenticated locally to your google account gcloud auth login
  1. make sure your gcloud config is correct for the instance you're trying to access:
gcloud config configurations list
  1. make a directory at the location you want to mount the file system, for example:
mkdir mnt/
mkdir mnt/<boxname>
  1. populate your ~/.ssh/config file with aliases for the instances in your project using gcloud compute config-ssh
  2. Download and install sshfs and FuseOSX: https://github.com/osxfuse/osxfuse/wiki/SSHFS#installation
  3. mount away!
sshfs -o IdentityFile=~/.ssh/google_compute_engine \
<username>@<insance-name>.<region>.<project>:/path/to/location \
<path/to/local/mount/folder>

Unmounting:

umount <path/to/local/mount/folder>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment