Sending SSH Command to Remote Mac (iTunes / play-pause)

Udo’s post has the steps, and you’ve already done 1, 2, 4 and 5.

If ~openhab exists (run echo ~openhab and see if it returns a valid folder path), then you can do the following instead, which will allow you to not specify the private key in the ssh command. If it does not exist, continue with Udo’s instructions.

Copy the private key to the openhab account’s home directory (I’m assuming you are using RSA keys)…
cp ~openhabian/.ssh/id_rsa ~openhab/.ssh/id_rsa

and change the owner to the openhab account…
chown openhab:openhab ~openhab/.ssh/id_rsa

Then test running the script as the openhab account and you should not be prompted for a password…
sudo -u openhab /etc/openhab2/scripts/iTunes.sh

The password prompt you were getting was coming from the SSH command, because the openhab account did not have the private key in ~openhab/.ssh. The password was for the xxxxx account that you using in the SSH command in the script. On the Mac, you already setup the public key for that user.

1 Like