Skip to content

FunctionBlock: PBCL_SysLinuxShell_1

Ciao,

Does FB FunctionBlock: PBCL_SysLinuxShell_1 could manage ssh command.

I try to send the command : rsync -vrah --remove-source-files -e ssh /opt/plcnext/logs/datalogger/ pxc@192.168.1.251:/home/pxc/Desktop/archivioPLC/

From controller shell on putty the command is working properly (password for remote user is needed), from the FB alway reurn an error.

The error is: Host key verification failed.rsync: connection unexpectedly closed (0 bytes received so far) [sender]rsync error: unexplained error (code 255) at ../rsync-3.1.3/io.c(226) [sender=3.1.3]

 

Do you have some suggestion?

Thank you.

 

Ciao

Samuele

Comments

  • Hi Samuele,

    I think that FB doesn't allow user input after the command is sent.

    If you google "use rsync without a password", you should hopefully find a method of using the rsync command(s) you want, without user interaction.

    Please let us know if you have any success with this, or not.

    ~ Martin.   

  • Hi Martin,

    I implement the rsync without password into the server.

    This is the command:

    cat ~/.ssh/id_rsa.pub | ssh pxc@192.168.1.251 "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"

    From shell on AXC2152 it's working, but in the FB the error persist.

    Please see the attached file. 

    The only way is try to use crontab.

    Do you have a sample to use cron on AXCF2152?

    Thank you.

     

    Samuele

  • Hi Samuele,

    The Linux shell function block opens a new shell session, so this could be causing the problem - perhaps the key is unknown in the new shell session.

    You could try to create a new key for the domain or use the rsync parameter that disables the key check:

    -e "ssh -o StrictHostKeyChecking=no"

    Unfortunately I don't have any examples of using cron, but you may need to solve the same problem there.

    ~ Martin.

  • Hi Martin,

    I don't understand the domain behavior. What do you mean with: The Linux shell function block opens a new shell session.

    The same should happen when I open different shells with putty, but everytime the ssh without password is working, so I don't undertsand your suggestion.

    Also, I don't create a new key, but simply use the one just present on AXC2152.

    I Tested  with the -e "ssh -o StrictHostKeyChecking=no" option and it doesn't work.

    I chek in the know host file on /opt/plcnext/.ssh/ folder and the host is inside this file, with the key.

    The same behavior didn't  happen scheduling a cron job, i tried last hours.

     

    Thank you 

    Samuele

     

  • Hi Samuele,

    I have discussed this again with the developer of the FB.

    The difference is that, in PuTTY, you are creating each new session as the admin user. The Function Block starts the session with plcnext_firmware privileges, which does not use the .ssh directory that is set up for the admin user.

    ~ Martin.

Sign In or Register to comment.