IT/Cloud/Remote Shares/MacOS

From msgwiki
< IT‎ | Cloud‎ | Remote Shares
Revision as of 11:21, 31 January 2020 by Itvte (talk | contribs)
Jump to navigation Jump to search
Access restrictions were established for this page. If you see this message, you have no access to this page.

Accessing an SSH share on MacOS

  1. This method works but is by no means perfect and could be drastically improved. See the 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>

What a proper installation looks like

/home/$USER
 |
 +-- msgvtefiles
      |
      +-- Use This.app
      |
      +-- msgvtefiles
           |
           +-- IT
           |
           +-- Admin
           |
           +-- etc

Known 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.
  2. The force unmount of the folder is not safe, but it has to be forced to fix errors
  3. If the folder is mounted and a document is opened followed by the mount breaking, then when the document is saved LibreOffice will error out and you risk losing data.
    1. This happened a couple times and both times the data was successfully recovered thanks to LibreOffice autosave
      1. The automatic recovery failed but I was able to extract the file from LibreOffice's autosave location.
    2. The file will save fine if before saving you run the app to ensure the mount is working

Making it (semi) automatic

  1. Create a standardized directory structure to help us
    • mkdir -p ~/msgvtefiles/msgvtefiles
    • Obviously replace msgvtefiles with the correct name
    • 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> will be something like "/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