Both RP boards share a private generated key. When I use Putty to log in via SSH to pi@PLC and execute: ssh pi@raspberrypi -t sudo shutdown -h -P now, it shuts down perfectly without asking for passwords or anything. Just as intended.
However it does not work via Codesys.
I use the same syntax above to shutdown(sudo shutdown -h now & disown) and restart(sudo reboot) pi@PLC without problems, however the code above does not seem to do anything regarding pi@raspberrypi.
Anyone have any idea what I am doing wrong?
Thanks in advance.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I would give this a try:
generate a script for example ssh-shutdown.sh with your command:
ssh pi@raspberrypi -t sudo shutdown -h -P now
and just execute then ssh-shutdown.sh by the codesys command.
Best Regards
Edwin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have 2 Raspberry pi boards:
- pi@PLC with the codesys project
- pi@raspberrypi (the other one)
I already made two buttons to shutdown and restart pi@PLC without problems.
Then I made a 3rd button to shutdown pi@raspberrypi with the following code:
Both RP boards share a private generated key. When I use Putty to log in via SSH to pi@PLC and execute: ssh pi@raspberrypi -t sudo shutdown -h -P now, it shuts down perfectly without asking for passwords or anything. Just as intended.
However it does not work via Codesys.
I use the same syntax above to shutdown(sudo shutdown -h now & disown) and restart(sudo reboot) pi@PLC without problems, however the code above does not seem to do anything regarding pi@raspberrypi.
Anyone have any idea what I am doing wrong?
Thanks in advance.
Hi,
I would give this a try:
generate a script for example ssh-shutdown.sh with your command:
ssh pi@raspberrypi -t sudo shutdown -h -P now
and just execute then ssh-shutdown.sh by the codesys command.
Best Regards
Edwin
Hello, look to the side.
PROGRAM POU_ST
VAR
pRes: POINTER TO SysProcess.SysTypes.RTS_IEC_RESULT;
StrName_Shutdown: STRING(255):= 'sudo shutdown now ';
END_VAR
SysProcessExecuteCommand((StrName_Shutdown) , pRes );
If you haven't done so, maybe add ssh to /etc/CODESYSControl_User.cfg:
[SysProcess]
Command.0=shutdown
Command.1=ssh
shutdown
is default. There's another option to allow all viaCommand=AllowAll
, but this is way too permissive.Thank you all for the feedback.
I used Edwin's suggestion and created a python script.
This seems to do the trick.
Kind regards