Hi, i am trying to turn the display of a second raspberry on and off via a ssh command.
As soon as it is working in the console i want to create an exec command for it.
However the console is always asking for a password which i have to insert manually:
[13:59:38] openhabian@openhab:~$ ssh pi@192.168.0.199 sudo reboot
The authenticity of host ‘192.168.0.199 (192.168.0.199)’ can’t be established.
ECDSA key fingerprint is SH####:lPO2##################.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.0.199’ (ECDSA) to the list of known hosts. pi@192.168.0.199’s password:
Connection to 192.168.0.199 closed by remote host.
After this was done once i can now power on and off the display via:
Thank you for the hints.
I googled some information and did this:
[15:36:37] openhabian@openhab:~$ sudo -u openhab ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/var/lib/openhab2/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /var/lib/openhab2/.ssh/id_rsa.
Your public key has been saved in /var/lib/openhab2/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:BEuJD"######" openhab@openhab
The key’s randomart image is:
±–[RSA 2048]----+
| “######” . .E=|
| o.“####”+o . =|
| o *X"###" oo|
| o. . .|
| S |
| |
| |
| |
| |
±—[SHA256]-----+
[15:40:39] openhabian@openhab:~$ sudo -u openhab ssh-copy-id -i /var/lib/openhab2/.ssh/id_rsa.pub pi@192.168.0.199
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: “/var/lib/openhab2/.ssh/id_rsa.pub”
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed – if you are prompted now it is to install the new keys
Now try logging into the machine, with: “ssh ‘pi@192.168.0.199’”
and check to make sure that only the key(s) you wanted were added.
[15:43:51] openhabian@openhab:~$ sudo ssh -i /var/lib/openhab2/.ssh/id_rsa.pub pi@192.168.0.199 sudo vcgencmd display_power 1The authenticity of host ‘192.168.0.199 (192.168.0.199)’ can’t be established.
ECDSA key fingerprint is SHA256:lPO2"###########".
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.0.199’ (ECDSA) to the list of known hosts.
Load key “/var/lib/openhab2/.ssh/id_rsa.pub”: invalid format pi@192.168.0.199’s password:
display_power=1