LaunchDaemon Access to System Keychain

Joined
Oct 20, 2011
Messages
3
Reaction score
0
Points
1
Hi guys, been tearing my hair out for three days since getting a Mac Mini server. I'm trying to periodically and automatically SSH a file to a remote site from my Server using launchctl, which I have been learning, having used 'cron' with (Gentoo) 'keychain' for years. I have a running shell script run from a System LaunchDaemon that performs the necessary SSH commands (and has done for a couple of years successfully on Linux, so no problems there), but I'm having no success retrieving the passphrase that I've attempted to store in the System Keychain (I think). To add the passphrase there I've tried just about everything, including just doing 'sudo sftp -i <path-to-private-key>' which asks for the passphrase and even though I choose store it, in the next user session it asks it again. Do I need to do anything special in the shell script to use this stored passphrase from the keychain? I used to have a line like this in the Linux version of the script:

[ -z "$HOSTNAME" ] && HOSTNAME=`uname -n`
. $HOME/.keychain/$HOSTNAME-sh 2>/dev/null
ssh-add -l 2>/dev/null | grep -q id_rsa || exit 1

which retrieved the appropriate keys into memory and meant I only ever had to type the passphrase once and then it would remember until the server rebooted.

Does anyone have a clue how to achieve this with a Mac? I should add that in my plist file, stored in /Library/LaunchDaemons/, I use the "UserName" key with the user that I want to run the script. Mind you, in three days I've also tried without this, letting root run the script, but this also asks for the passphrase each time the shell script is run.

Other than desperately searching the Internet without finding anything concrete I really have nothing to go on. Anyone can offer some help? I can't imagine no one has done something like this...
 
OP
R
Joined
Oct 20, 2011
Messages
3
Reaction score
0
Points
1
Well, for the time being I have it working with good old keychain (Keychain - Funtoo Linux) bypassing the Mac KeyChain so at least I spare some of the remaining hair. Would still be nice to know how this can be done the proper Mac way though...
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top