Setting up a mac remotely

I want to be able to get to my wife’s mac, in another city. She is an unsophisticated user, and I’d like to be able to help her when she needs help, but I can’t ask her to do very much setup. I also want to be able to provide backup for her files.

The first step was to outfit her with one of the little gateway pis previously described. Once that was done, we managed, together, to enable me to get to her mac with ssh, by way of the pi tunnel. And we managed to set up an account on her mac under my name.

Once I was able to get to her Mac with ssh, I was able to create a backup, and get it transferred, initially to the pi, and then from there to my house. Later I’ll describe what I did to automate this.

The next task was to enable me to get to the mac with vnc. I found a number of articles. This is the set of instructions I pieced together which I followed:

First, I enabled “fast user switching” so that the mac would allow both of us to have logged in sessions, so that I could log in as me, and not disturb her session.

defaults write /Library/Preferences/.GlobalPreferences \          MultipleSessionEnabled -bool YES

Then a set of changes to enable VNC and set the password. The following are done with sudo or as root.

Once/System/Library/CoreServices/RemoteManagement/ -configure -allowAccessFor -allUsers -privs -all

/System/Library/CoreServices/RemoteManagement/ -configure -clientopts -setvnclegacy -vnclegacy yes

/System/Library/CoreServices/RemoteManagement/ -configure -clientopts - setvncpw -vncpw <password>

/System/Library/CoreServices/RemoteManagement/ -restart -agent -console

I did some additional setup on her mac, including getting a postfix service set up so that if there were problems with any of the scripts I created they could send me email. I wasn’t able to use the simple postfix setups I use on the gateway pis, because the mac has some special file locations and naming, but it wasn’t too hard. I simply used their with appropriate modifications, instead of the generic one I use on the gateway pis.

The final step is to arrange for the backups from the mac to the gateway pi to take place each night. I am accustomed to just doing this with crontab. I’ve never done this on a mac. Gulp.

The short version is, on a mac you do this with launchd. I wrote a plist file, which is a file describing what you want launched and when, like a systemd file. I put the plist file (net.wmbuck.amaranth.backup.plist) into /Library/LaunchDaemons, The effect of this plist file is to start a script once a day. I put the script (/net.wmbuck.amaranth.backup) into /usr/local/libexec.

I had a lot of trouble with this, and did a lot of practicing on carraway before I was satisfied. At the end of the day I did a lot of experimental changes and some of them may not have been right and not all of them were reverted. One, which I think is pretty surely correct, is that I had to put a key into the plist: <key>AbandonProcessGroup</key><true/>.

I think that I needed this because the script attempts to send mail, and according to my reading the reason the mail was not getting sent was that after a launchd process completes, it “cleans up” after itself, killing any processes left still running – and when my script sent mail, a process created to do the maildrop to postfix gets killed before it ever gets going. At another point I changed the script from bash to sh, but in retrospect I think that was not necessary.