IT/Cloud/Remote Shares/MacOS

From msgwiki
Jump to navigation Jump to search

Accessing an SSH share on MacOS

  1. This method works but is not automatic and could be drastically improved. See Issues
  2. I started to make a bash script to do everything here but ran into problems and decided it wasn't worth it

Installation

Use Terminal

  1. Install Homebrew
  2. Install osxfuse and sshfs
    • brew cask install osxfuse
    • brew cask install sshfs
  3. SSHFS is now installed

Mounting a folder

  1. Using Terminal
    • echo "<password>" | /usr/local/bin/sshfs -o password_stdin <username>@<hostname>:<remote folder (must be relative to / without a ~)> <local folder>

Issues

  1. The big issue is that although the folder is mounted it is not persistent. It breaks if the computer even goes offline, much less restarts. MacOS does not have an fstab file, (actually it does but the OS never uses it. WHY?) so we make a script to mount it again automatically.
    1. The issue with that is that Mac doesn't let you run bash scripts easily without Terminal. So we use the Mac default program Automator to make ourselves an app to run the scripts.

Making it (semi) automatic

I have not

  1. Create a standardized directory structure to help us
    • mkdir -p ~/msgvtefiles/msgvtefiles
    • The first msgvtefiles will contain our script and the second will be the actual mount
  2. Create the script
    1. Open Automator
    2. Create new Application
    3. Add into the workflow "Run Shell Script"
      • Command: umount -f /home/$USER/msgvtefiles/msgvtefiles
      • This is to prevent errors about the folder already being mounted (Because errors means I get emails whether the errors mean anything or not)
      • Also if you leave this out the mount will sometimes get stuck and need to be forcibly unmounted.
      • I realize this isn't very safe but it is here for lack of a better way
    4. Add another "Run Shell Script" into the workflow
      • Command: echo "<password for server>" | /usr/local/bin/sshfs -o password_stdin <username>@<hostname>:<remote folder (must be relative to / without a ~)> <local folder>
      • <remote folder> will be something like "/home/msgvte/msgvtefiles"
      • <local folder> should be "/home/$USER/msgvtefiles/msgvtefiles"
    5. Test and deal with inevitable errors
    6. Save in ~/msgvtefiles
  3. Now we can remount the share by double clicking the app we made.
  4. Optional: Put the ~/msgvtefiles folder in the favorites in Finder
    • Mac users don't really use the home folder so they may have a hard time finding it otherwise