Secure communication between shell-php and Linux hosts

Source: Internet
Author: User
The function that you want to implement is this:
Client PHP page, perform a task, such as a new site, in some way to notify the back end of the NC listener, and then execute the relevant script, instead of creating an FTP account, create a new directory and so on.

But how can I send a message to NC via PHP?
For advice

The following are the PHP clients:

$fp = fsockopen ("udp://127.0.0.1",40030,$errno,$errstr,30);if(!$fp){    
";}else{ fwrite($fp,"Hello nc"); echo "Success"; fclose($fp);}

The following is the Shell service side:

#!/bin/bashkillall 'nc' >/dev/null 2>&1nc -l -u 40030 | while read Linedo    echo $Linedone

But why not output it?

Reply content:

The function that you want to implement is this:
Client PHP page, perform a task, such as a new site, in some way to notify the back end of the NC listener, and then execute the relevant script, instead of creating an FTP account, create a new directory and so on.

But how can I send a message to NC via PHP?
For advice

The following are the PHP clients:

$fp = fsockopen ("udp://127.0.0.1",40030,$errno,$errstr,30);if(!$fp){    
";}else{ fwrite($fp,"Hello nc"); echo "Success"; fclose($fp);}

The following is the Shell service side:

#!/bin/bashkillall 'nc' >/dev/null 2>&1nc -l -u 40030 | while read Linedo    echo $Linedone

But why not output it?

Because bash's read command is read a line from the standard input and split it into fields.

So you need to output a line break:fwrite($fp,"Hello nc\n");

And why don't you use Popen to execute scripts directly in PHP, why superfluous use NC? You close the NC connection and close it off.

Back end why with NC, back end can also be written in PHP, such as the use of Workerman such a service framework

I don't know what you're doing. However, if you mention security, then either do not use UDP, or add your own authentication and integrity checks. Especially you use NC to deal with UDP, so that the message line is gone.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.