Q: Disk image can mount from local terminal with "open" command but not via ssh
I have a disk image "backup_image.sparsebundle". If I go to the terminal on my machine and type "open backup_image.sparsebundle" the disk image mounts as expected. No problems. If I secure shell (ssh) log in from a remote Mac and execute the same "open backup_image.sparsebundle" a warning dialog pops up and states that "The following disk images couldn't be opened" followed by my disk name. This is incredibly odd because it used to work just fine. I didn't think there were any ACL differences between a local terminal shell and remote ssh. I mean a shell is a shell right? Or, it used to be and now it isn't? I'm not doing anything obviously incorrect (to me); I'm the same user locally and remotely, same path to disk image. This used to work fine before Mountain Lion.
Background: All of this started because I wrote a script that would ssh in to a remote machine, open the disk image on that remote machine, mount it across the network over afp and rsync. If I leave the disk image mounted on the remote machine, the script runs fine but if the image is close and I try to remotely open the image as I always did, it fails. The only thing that has changed in the system is, now, both machines are running Mountain Lion. Odd.
Suggestions?
MacBook Pro, OS X Mountain Lion (10.8.2)
Posted on Oct 28, 2012 1:48 AM
Storing the password for the remote disk image in the local keychain of the computer running the script (in to a variable), then passing it accross to the remote machine worked. I'm not sure why all of this changed moving from Lion to Mountain Lion but I suppose it is slightly more secure.
To programatically mount and sync a remote encrypted disk:
#!/bin/bash
if [ -n "`mount | grep ~/sync`" ]; then
echo "Already mounted"
else
pw=$(security -v find-generic-password -w -D "application password")
ssh -o ConnectTimeout=1 user@xxx.xxx.xxx.xxx "echo $pw | hdiutil attach /Users/user/backup_image.sparsebundle"
mkdir ~/sync
mount_afp -s "afp://matdup01:Armbwan1@192.168.1.102/Disk Image" ~/sync
fi
if [ $? -eq 0 ]; then
echo "Mount succeeded!"
else
echo "Mount Failed"
exit 0
fi
rsync -vrxtu --delete-before --exclude _* "/Volumes/Media/new Media/" ~/sync/new\ media/
umount ~/sync
rmdir ~/sync
exit
Posted on Oct 29, 2012 2:56 AM
