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

thats not my personality :wink: - i edited my previous post

i dont get it :frowning: - thats my command line, that works

thats my .item:

Switch iTunes {nh="", exec=">[*:/etc/openhab2/scripts/]"}


[INFO ] [ab.binding.exec.internal.ExecBinding] - executed commandLine 'ssh plauf@ 'osascript -e "tell application iTunes to playpause"''

Try saving the items file again and watch the log. If there’s an error, it won’t load it and it will log the error. If it saves without error, then all I can think of is to restart OH.

no error - no luck after restart :frowning:

Does the script execute if you just run /etc/openhab2/scripts/

it seems that i need a password again - wtf ?



Okay i fixed the password problem


Based on this, openhab is the user that is running OH and will be running the script. I do not know openhabian, but I would try running the script as that user and setup the RSA key for that account. Once that is working, the Exec binding should be able to execute the script. Or you should be able to go back to the original way without the script.

1 Like

i tried another way, i created a new file and it looks like this now:


When i try this script i get a “Permission denied”
( i already made i executable “sudo chmod u+x” )

[ERROR] [ab.binding.exec.internal.ExecBinding] - couldn't execute commandLine '/etc/openhab2/scripts/' Cannot run program "/etc/openhab2/scripts/": error=13, Permission denied

Check out the posts I linked. Your OH is running under the openhab account. That is the account that needs the permissions to run the script, or whatever else you want the Exec binding to execute.

1 Like

you are probably right, and i understand that i need to change the user but i dont know how to do so :frowning: i am a beginner in the command line and do not understand why the openhabian image is that confusing for beginners – i thought its the hasslefree version :smiley: haha

thanks for all your ideas, links and help so far! learned a lot out of it so far :wink: thanks!

sudo chown openhab: /etc/openhab2/scripts/

should fix this.

sudo                               : is for command as root
chown                              : change owner
openhab                            : user name
:                                  : change group name accordingly 
/etc/openhab2/scripts/  : name of file to change the ownership.
1 Like

a pity - its not :frowning: Radio is still playing Music…

i think you didnt read the whole thread :wink: - i created two scripts, one with “openhabian” and one with “openhab” just for testing - but still no luck…


this is still working but my exec-binding is not :frowning:

What’s the exact content of and

In question of file permissions: the simple way would be to

sudo chmod 755 /etc/openhab2/scripts/

to allow editing only for user openhab, but reading and execution for all users. Later, when all things work the right way, you can change the permissions to a more safe configuration.

both looks the same:

toggleResult=`ssh 'osascript -e "tell application \"iTunes\" to playpause"'`
echo "$toggleResult"

i tried your file permissions, but still no luck

What’s the output of

sudo -u openhab /etc/openhab2/scripts/


i needed a password

i tried this - but whats the default password for the “openhab” user ?



So now the problem is reduced to the login via ssh :slight_smile:

User username is secured via password. There is no (good) way to use password for scripted ssh. Instead you should use private keys to login. The steps for this:

  1. Create a pair of keys either at your raspberry or at your mac with empty password (i.e. no password at all)
    At your raspberry this is done with ssh-keygen
  2. either copy the public key to your mac or copy the private key to your raspberry, depending on where you did the key creation
  3. move the private key to /etc/openhab2/.ssh/keyfile (where keyfile is a meaningful name, e.g. name of your mac)
  4. chmod this key file to 600 (sudo chmod 600 /etc/openhab2/.ssh/keyfile)
  5. at your mac, change to the user profile and add the public key to your system. As I don’t own a mac, I don’t know the exact steps to place the public key, so please use google for that.
  6. add the filename to your script:
toggleResult=`ssh -i /etc/openhab2/.ssh/keyfile 'osascript -e "tell application \"iTunes\" to playpause"'`

This should result in a passwordless login for user openhab at your Mac with user username

1 Like

i already created the keys, but as @5iver said,
i need to do this on the “openhab” user and not on the “openhabian” user and i dont know how to do so…

i tried “su openhab” but i dont know the default password !?
i found an interesting thread:

No, you don’t need to.

The only thing to do is, to give the correct permissions and the correct file location.

There is no relation between private key and user account, in fact, you could use whatever private/public key pair you want to use:

  1. at the destination computer you need a public key, this key has to be allowed to be used to login by a user
  2. at the source computer you need an account with a private key
  3. you need to know the username corresponding to the public file

Altough there might be a username within the key file, it isn’t part of authentication process.

1 Like

okay, but what to do ? :slight_smile: sorry for being confused with the exec-binding…


This is no problem with exec binding, only a problem with correct permissions