Simple web-controlled shell scripting method

Source: Internet
Author: User

1) View PHP running users:


<?php

System (' id-a ');

?>


General PHP running user is Apache


2) do a key trust for Apache users:


2.1)

First look at the Apache user information:

# Su-apache

This account was currently not available.

# Cat/etc/passwd|grep Apache

Apache:x:48:48:apache:/var/www:/sbin/nologin

Switch

Apache:x:48:48:apache:/var/www:/bin/bash


2.2)

Root User action:

Mkdir/var/www/.ssh

Chown Apache. /var/www/.ssh


2.3)

Then switch to Apache User:

Su-apache

SSH-KEYGEN-T RSA


2.4)

Root user, and finally change back to Nologin:

Apache:x:48:48:apache:/var/www:/sbin/nologin


3) Page wording:


3.1)

Cat/var/www/html/function/restart.html


<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>

<title> Restart Service </title>

<body>

<p>

<script language= "JavaScript" >

function Checkyes () {

if (!confirm ("Confirm to restart?") ")) {

Window.event.returnValue = false;

}

}

</script>

<form action= "restart.php" target= "_blank" method= "get" >

<input name= "" type= "submit" value= "Restart Service" onclick= "Checkyes ()"/></form>

</p>

</body>



3.2)

cat/var/www/html/function/restart.php


<?php

System ("ssh [email protected]/root/scripts/test.sh");

?>



3.3)

Apache Configuration Riga Password Verification:

<Directory/var/www/html/function/>

AuthType Basic

AuthName SYS

authuserfile/var/www/html/function/.htpasswd

Require user sys

</Directory>


HTPASSWD-BC/VAR/WWW/HTML/FUNCTION/.HTPASSWD SYS 123456


3.4)

Make a hyperlink embed another page

<a href= "http://x.x.x.x/function/restart.html" target= "_blank" > Restart </a>

Simple web-controlled shell scripting method

Related Article

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.