IT/Cloud/Remote Shares/MacOS: Difference between revisions

From msgwiki
< IT‎ | Cloud‎ | Remote Shares
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.
No edit summary
No edit summary
Line 1: Line 1:
=== Accessing an SSH share on MacOS ===
= Accessing an SSH share on MacOS =
# This method works but is by no means perfect and could be drastically improved.  See the [https://msgwiki.msgeducation.com/index.php?title=IT/Cloud/Remote_Shares/MacOS#Known_issues issues]
# This method works but is by no means perfect and could be drastically improved.  See the [https://msgwiki.msgeducation.com/index.php?title=IT/Cloud/Remote_Shares/MacOS#Known_issues issues]
# I started to make a bash script to do everything here but ran into problems and decided it wasn't worth it
# I started to make a bash script to do everything here but ran into problems and decided it wasn't worth it


==== Installation ====
== Installation ==


Use Terminal
Use Terminal
Line 14: Line 14:
# SSHFS is now installed
# SSHFS is now installed


==== Mounting a folder ====
== Mounting a folder ==


# Using Terminal
# Using Terminal
Line 20: Line 20:
#
#


==== Known issues ====
== Known issues ==


# 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.   
# 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.   
Line 30: Line 30:
## The file will save fine if before saving you run the app to ensure the mount is working
## The file will save fine if before saving you run the app to ensure the mount is working


==== Making it (semi) automatic ====
== Making it (semi) automatic ==


# Create a standardized directory structure to help us
# Create a standardized directory structure to help us

Revision as of 11:15, 31 January 2020

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>

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
    • 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