First things first Linux is not my first OS so any help would be greatly received.
I need to shutdown my media pc from Openhab, i have a exec thing to run “ssh root@192.168.0.84 reboot -h now”. I have gotten some success with another post from this forum in that i can execute the command from my openhabian cmd line without asking for the password by swapping ssh keys.
Running from the command line i get:
[22:12:57] openhabian@homeauto:~$ ssh root@192.168.0.84 reboot -h now
Connection to 192.168.0.84 closed by remote host. (it reboots as requested)
When running it from within Openhab by rule or switch i get an output of:
exec_command_74cce7f4_output changed from Pseudo-terminal will not be allocated because stdin is not a terminal.
Host key verification failed.
Failed to write reboot parameter file: Permission denied
Pseudo-terminal will not be allocated because stdin is not a terminal.
Host key verification failed.
Failed to write reboot parameter file: Permission denied to Host key verification failed.
Host key verification failed.
Your issue here is that you OH is operating in a java machine and not a shell so you need to give java the permission by giving it ssh keys. There have been threads about this previously.
Mostly right but not exactly how I would put it. The real problem isn’t really that it to running from Java, but that it is running as the openhab user.
So @rsemmens needs to generate keys for the opengab user and put them in ~openhab/.ssh (which maps to /var/lib/openhab2 for installed OH) or copy the keys for the openhabian user there. Make sure that the key files are only user readable and that they after owned by openhab:openhab.
In case it helps out somebody down the line here’s what i did.
After reading the post from @rlkoshak i realised that Openhab was running from another user ‘openhab’ and i was doing everything from ‘openhabian’.
So the fix, i copied the SSH keys to the openhab user folder and set the permissions for the files to the openhab user.
sudo cp ~openhabian/.ssh/* ~openhab/.ssh/
sudo chown -R openhab:openhab ~openhab/.ssh/ (for each of the files)