Realization of the server side of remote management system based on Linux

Realization of the server side of remote management system based on Linux

 

Summary

This subject is based on the Linux operating system, and the main purpose is to make the remote management work of system administrators more convenient, simple and friendly. The main functions realized are file operation, command operation, system operation, process operation and network operation, which basically cover all aspects of system management. In design, the B/S structure is adopted, so that the system can be easily upgraded and users can access the server from various platforms; the security access technology is adopted to make the access and management more secure; the simple and beautiful The advanced interface display technology makes the user's browsing fast and comfortable.

The system developed by this topic needs to be installed and run on the Linux system. The system administrator can log in remotely using a browser. After passing the verification, it is convenient to view the operating status of the system, manage the system, and configure the network. , to analyze the data, it should be noted that the root authority and password of the remote server must be used to log in to the system, and in order to ensure the safety of the system and prevent accidents, the administrator can only operate specific tasks. The main significance of this topic is that PHP can be used for system management, and the developed system can make system administrators manage remote systems conveniently.

Key words : remote management; B/S structure; secure access; Linux; PHP

1 Introduction

1.1 Subject background

1.2 Research status at home and abroad

1.3 Significance of this research

1.4 Research method of this topic

2 needs analysis

2.1 Task overview

2.1.1 Development goals

2.1.2  Development tools

2.1.3  Development environment

2.1.4  Developers

2.1.5  Operating environment

2.1.6  Conditional restrictions

2.2 Function Analysis

2.3 Workflow

2.4 Performance Analysis

3 overall design

3.1 System Architecture

3.2 Module Division

4 specific realization

4.1 Secure Access Module

4.2 File Operation Module

4.3 Command operation module

4.4 Process operation module

4.5 System Operation Module

4.6 Network Operation Module

5 system test

5.1 Secure Access Module

5.2 File Operation Module

5.3 Command operation module

5.4 Process operation module

5.5 System Operation Module

5.6 Network Operation Module

conclusion    

references

thank you    

statement    

1introduction

1.1 Subject background 

Remote management is a technology in which one computer (the master remote/client) remotely controls another computer (the controlled host/server) on the network. The remote here is not a literal long distance. It refers to controlling the remote computer through the network, but most of the time what we call remote control often refers to the remote control in the local area network. When the operator uses the host computer to control the controlled computer, it is like sitting in front of the screen of the controlled computer, and can start the application program of the controlled computer, use the files and materials of the controlled computer, and even Use the external printing device (printer) and communication device (modem or leased line, etc.) of the controlled computer to print and access the Internet, just like you use the remote control to control the volume of the TV, change the channel or switch the TV. However, there is a concept that needs to be clarified, that is, the host computer only transmits the keyboard and mouse commands to the remote computer, and at the same time returns the screen image of the controlled computer through the communication line. That is to say, it seems that our control of the controlled computer is carried out on the computer in front of us, but it is actually realized on the remote computer. Whether opening files, surfing the Internet, downloading, etc. are all stored in the remote controlled computer. in the terminal computer.

For system administrators who are new to Linux, it is simply an impossible task to complete various key system configurations correctly and efficiently. Even an experienced Linux administrator often struggles with the format of some complex configuration files. Therefore, having a GUI management tool on Linux has always been a good wish of the majority of Unix lovers. Although Linux has its own SSH character interface remote management tool, it is still a bit clumsy and boring for the difficulties brought about by the continuous upgrading of SSH, the friendly graphical interface, and the ease of use of the B/S structure. The Web management method makes this software both have The ability of local and remote management, access control and SSL support provide adequate security for remote management. So we write this software to manage remote Linux systems better and easier, thereby reducing the burden on system administrators.

1.2 Research status at home and abroad

Judging from literature and network resources, there have been similar software abroad, such as Webmin and PHPWebmin.

These softwares are all in English, and there is almost no Chinese version. Many domestic system administrators are not used to them. Moreover, some software is written in Perl language, which is not satisfactory in terms of efficiency and breadth of use.

1.3 Significance of this research 

For system administrators, managing the entire system is a very complicated and troublesome job, especially the remote management of servers is very important for system administrators. The development of this software is to facilitate the system administrator to manage the local and remote servers installed with the Linux system , to increase the convenience of management, and to use the B/S structure to reduce the workload of the administrator on the other hand. After logging in remotely with a browser, administrators can easily check the running status of the server, configure network services, analyze some data, and respond quickly to abnormal phenomena.

One of the challenges of moving from managing a Windows environment to managing a Linux environment is that you need to learn to take advantage of new tools. As an administrator, you want to understand the details of the operating system in order to get the most out of it. However, when you are still in the learning stage, you need to do specific work. In order to speed up your progress in mastering Linux, we install such a remote management program, which is very convenient for system administrators.

1.4 Research method of this topic 

The development of this system requires the use of B/S structure, simulating Webmin for design and development. Therefore, this graduation project should first analyze the relevant functions of Webmin, and write a demand analysis in combination with the relevant requirements of this graduation project; secondly, comprehensively use the relevant knowledge learned before to select familiar development tools to develop this graduation project; In the design, based on the requirement analysis, write out the system development plan, the implementation process and the implementation methods of related issues; at the same time, in the development design and implementation, it is necessary to save the relevant design documents to prepare for the writing of the graduation thesis later Materials; Finally, after the system development is completed, debug and test run, make relevant records of debugging and test run, and prepare materials for the writing of the graduation thesis later.

The main methods are: first, only write the file operation part to understand the working method and general appearance of the system, then gradually add other functions and modules, and finally modify the whole system to complete the system.

2 needs analysis

2.1 Task overview

      1.  development goals

1. Be able to log in to the remote host safely and perform safe interaction during the management process.

2. It can manage the file system of the remote host, and can view files or folders,

 Create, delete, move, upload, etc.

3. Able to send commands to the remote host for interpretation and execution and send back the results of the execution. 4. Be able to view and manage the running processes of the remote host.

5. Able to manage the remote host system, you can view system information, shut down or restart, modify

passwords, manage users and groups, manage software packages, and more.

6. Be able to manage the network services of remote hosts, manage Apache servers, manage

Manage DNS server, manage MySQL server, manage SSH server and manage DHCP

Server, view network parameters, configure network parameters and other operations.

7. Make remote management more humane, simpler, more convenient and more friendly.

8. Make the software easy to upgrade, modify, expand, and easy to use.

 development tools

The development language mainly uses PHP and HTML, and  SHELL or C is used where PHP cannot solve the problem.

 development environment

OS: Fedora Core 5

PHP reference: PHP 5.1

Web server: APACHE2

Browser: Mozilla firefox 2.0

 Developer

Sun Zexi is mainly responsible for server-side development.

Xu Bin is mainly responsible for the development of the client.

 operating environment

The software runs on a remote host with Linux operating system and Apache server installed. Before running, you need to start the Apache server and make some settings.

 Conditions

The system login must be logged in with the root authority and password of the remote server, and in order to ensure the security of the system and prevent unexpected events, the administrator can only operate specific tasks. If the system is installed in other operating systems, such as windows operating system, some modules may not work or cannot run correctly.

2.2 Function Analysis

According to the requirements and goals of this project, it can be learned that the system mainly has the following functions:

1. Secure access

Secure access refers to the use of HTTPS protocol and SSL socket to log in to the remote host when logging in. The user name and password cannot be detected by hackers or malicious attackers, and security access technology should also be adopted during the management process to prevent Loss, interception or attack of important data.

2. File operation

File operations mainly manage the file system, including viewing file or directory information, creating new files or directories, deleting files or directories, copying files or directories, running files, uploading files, downloading files, and so on.

3. Command operation

Command operation is to send commands to the remote host, the server interprets and executes various SHELL commands, and sends the executed results to the remote host for display.

4. Process operation

Process operation is to manage the running process of the remote host, mainly including viewing or terminating the running process, viewing the list of opened services (port number), managing the opened service, viewing all running processes of the current system and can Perform related operations on the process .

5. System operation

System operation is the system management of the Linux system of the remote host, mainly including shutting down or restarting, changing passwords, viewing system information, managing users and groups, and managing software packages.

6. Network operation

Network operation is the management of network services of remote hosts, mainly including managing Apache server, managing DNS server, managing MySQL server, managing SSH server, managing DHCP server, viewing network parameters, and configuring network parameters.

2.3 Workflow

According to the design goals and requirements of the system, it can be determined that the workflow of the system is divided into three parts in general: authentication process, management process, and logout process.

The workflow of the whole system is shown in Figure 1:

 

Figure 1 Workflow

1. Authentication process

The administrator logs in to the remote management system through a browser, and enters the user name and password of the system. If the user name or password is wrong, an error message will be displayed and a prompt to re-enter it will be prompted; if it is correct, it will enter the management system, obtain certain permissions, and manage system services. . The authentication process should be carried out in a secure situation and cannot be transmitted in plain text.

2. Management process

When the user enters the system correctly, he can manage the system, click on a management module, set up a certain service, the system sends commands to the Web server through the network, and interacts with the server. The server obtains the commands through the PHP engine analysis, calls the corresponding script and executes it. , get the result back to the remote host's browser.

3. Cancellation process

After the administrator completes the update or management of the remote host, he can click logout to exit the remote management system. The system sends a logout command to the server, and the server makes the logged-in user lose the management authority, cuts off the connection between the user and the server, and returns to the management system login page.

2.4 Performance Analysis

  According to the requirements and goals of this topic, and the current technical situation, it can be determined that the system should reach

to the following target:

1. The system can handle multiple users connecting to the server at the same time without any problems (say 100).

2. The system can return the execution result in time, and can prompt when the command cannot be executed correctly.

3. The system should be able to correctly identify when the page is closed abnormally, and automatically disconnect from the remote client.

4. The system must prevent access to individual files, no matter what kind of files you want to access, you must go through the main page.

5. For the abnormality that occurs during system execution, the program can correctly identify and display relevant information for prompting.

6. The program should prevent the execution of incorrect or illegal commands, and prevent the entire system from crashing or disconnecting the connection or crashing the remote server due to the execution of a certain command during the running of the program.   

3 overall design

3.1 System Architecture

Because the system adopts B/S mode and carries out remote management, the whole system can be divided into five modules, namely client, Internet, Linux operating system, Apache server, and PHP interpreter.

The client is a browser, and the client can remotely use the browser to log in to the server to manage the remote Linux system.

The Internet is the medium connecting the server and the client, and is used to transmit commands and data.

The Linux operating system runs on the remote server to manage the entire system, and the developed programs also run on the Linux operating system.

The Apache server is used by the web server to transmit web pages, and calls the PHP engine to interpret and execute the PHP script, and transmits the result to the remote browser.

The PHP interpreter is used to interpret and execute PHP scripts. The PHP interpreter interprets different scripts according to different calling parameters of Apache, and returns the html file obtained after execution to the Apache server.

The framework of the system can be represented by Figure 2:

 

Figure 2 System architecture

3.2 Module Division

According to the previous requirements analysis and system architecture, the system can be divided into six modules as shown in Figure 3.

 

Figure 3 System modules

  1. Security Access Module

It is mainly responsible for the safe access of the client to the server, mainly using access control technology and encryption technology. Access control technology is adopted in the file system on the server side, and encryption technology is used in the transmission process between the server side and the client side.

  1. file operation module

It is mainly responsible for operating the file system of the remote Linux operating system, which is the basis for operating the remote host. When performing file operations for the first time, the interface displays the directory where the system script file is located and the attributes of the file, and then displays the command buttons that can be operated, and there are text boxes and commands for converting directories at the top of the interface. Mainly use PHP's cookie to pass commands, and in terms of specific operations, mainly use PHP's file IO function to achieve. In terms of display, a format class is written, and the corresponding function of this class can be called to format or display data.

  1. command operation module

It is mainly responsible for interpreting and executing the SHELL command sent by the client, and returning the result in time. When doing this module, you must pay attention to the timeliness of the result return and the correct prompt of the wrong command. Mainly use HTML's POST method to transmit commands to the server, and then use PHP's system functions system, exec, and passthru to execute corresponding commands and transmit the execution results to the browser.

  1. Process operation module

It is mainly responsible for displaying the processes of the remote Linux operating system, and can operate each process, such as killing a certain process. Mainly use the system function to execute the SHELL command ps and grep to get the process list, and display it in a table on the browser side, and use the posix_kill function to kill a certain process.

  1. System Operation Module

It is mainly responsible for the operation of the main system management of Linux, and can use these system operations to perform simple system management on the remote Linux system. The general idea is to use PHP's _POST array to get the corresponding transmitted command, then use PHP's system function to execute the corresponding SHELL command, and transmit the result to the server.

  1. Network Operations Module

It mainly manages and configures the network of the remote Linux system simply. The general idea of ​​the implementation is to modify the access rights of some files related to network management on the server side so that Apache can access and modify these files, use the _POST array of PHP to get the corresponding transmitted network operation commands, and then use PHP The system function executes the corresponding SHELL command and transmits the result to the server.

4 specific realization

4.1 Secure Access Module

Secure access is primarily achieved through native access control files and PHP script authentication.

1. Host access control file

In the remote host, the apache server should be started, and the access control option of the directory to be accessed should be added in the apache configuration file. Then create access control files .htaccess and .remoteadminpasswd in the directory to be accessed. The .htaccess file defines the path to the username and password files and some other control options. The .remoteadminpasswd file has usernames and encrypted passwords.

Apache is configured for directory protection and basic authentication, but some server configuration is required in order to elevate user privileges.

  1. Check the httpd.conf file to find the User field, and check the Apache startup user (the default is apache);
  2. Edit the /etc/passwd file, find the apache user line, and modify its shell (default is /bin/nologin or /bin/false) to /bin/bash;
  3. Edit the /etc/sudoers file, and add apache ALL=NOPASSWORD:ALL to the next line of the root ALL=(ALL)ALL field in the file, so that the apache user can execute all commands through the sudo command.

After this configuration, the apache user can obtain root privileges only by using the sudo command.

In order to ensure the security of the system, access control is performed on the directory of the Apache Web server here, using the .htaccess access file and the htpasswd program to establish an ACL for a directory to authenticate users, and set the SSL connection in the .htaccess file , perfect security.

Assume that PHPWebmin is located in the /var/www/phpwebmin directory.

1) Configure httpd.Conf

Open the Apache configuration file httpd.Conf (under the /etc/httpd/conf/ directory by default) with the vi editor, find the <Directory "/var/www"> field, and add or modify it in the following attribute settings

AllowOverride ALL //This parameter sets which directories are protected with .ltaccess;

2) Create an ACL for the protected directory

Enter the phpwebmin directory, cd /var/www/phpwebmin, create a hidden file in this directory. htaccess (you must add a dot before the htaccess file, if you don’t do this, you can’t create an ACL, because the dot means creating a hidden file ) vi .htaccess, enter the following code in the .htaccess file:

SSLRequireSSL //Use SSL secure connection

AuthName "PHP Webmin" //Authentication name

AuthType Basic

require valid-user //Allow all users in the password file to access

AuthUserFile /var/www/phpwebmin/.phpwebminpasswd //identity data file;

3) Create a user authentication database

Enter the following password at the command line to create the user authentication database file, you will be asked to create a password for the user admin:

htpasswd -c /var/www/phpwebmin/.phpwebminpasswd admin

New password:

Re-type new password:

The content of the created .phpweminpasswd file is similar to:

admin:Op96DPmXTKy5w //User name: MD5 encrypted password

If the system has not installed htpasswd, you can also generate a user name and password online and put it into the .phpwebminpasswd file.

In this way, a user account database has been established for the Apache server, directory protection has been implemented for the phpwebmin directory, and basic user authentication has been implemented. It is necessary to use a secure connection https://localhost/phpwebmin/ to access, and a pop-up will pop up during the access process. Validation dialog.

2. Authentication of PHP scripts

Use the _GET array to determine whether to log in or log out. If it is logged in, verify whether the password is correct. If it is correct, enter the management interface and set a cookie on the client to record the login information. Otherwise, a corresponding error message will be prompted. The verification process is shown in Figure 4:

 

Figure 4 Identity verification process

The main code for authentication is as follows:

if ($_GET['action'] == "logout")

{

setcookie("adminpass", "");

echo"<meta http-equiv=\"refresh\" ontent=\"3;URL=".$self."\">";

echo "<span style=\"font-size: 12px; font-family: Verdana\">注

Pin successfully......<p><a href=\"".$self."\">Automatically exit after three seconds or click here to exit the program interface >>></a></span>" ;

ob_end_flush();

exit;

}

if ($_POST['do'] == 'login')

{

$thepass=trim($_POST['adminpass']);

if($admin['pass'] == $thepass)

{

setcookie("adminpass", $thepass, time() + (1 * 24 * 3600));

echo "<meta http-equiv=

\"refresh\" content=\"3;URL=".$url."\">";

echo "<span style=\"font-size: 12px; font-family: Verdana\">Successful login......<p><a href=\"".$url."\">Three seconds Automatically jump after that or click here to enter the program interface >>></a></span>";

exit;

}

else

{

echo "Password error, please re-enter</br>";

}

}

if(isset($_COOKIE['adminpass']))

{

if ($_COOKIE['adminpass'] != $admin['pass'])

{

loginpage();

}

else

{

loginpage();

}

}

4.2 File Operation Module

There are many types of file operations, mainly including viewing file or directory information, creating a new file or directory, deleting a file or directory, copying a file or directory, running a file, uploading a file, and downloading a file.

The operation of the file is the same as that of operating the file locally, but the form is different. When the user selects one or part of the file, he can click the corresponding command button to generate the corresponding action. Mainly use PHP's cookie to pass commands, and in terms of specific operations, mainly use PHP's file IO function to achieve. In terms of display, a format class is written, and the corresponding function of this class can be called to format or display data.

The file operation process is shown in Figure 5:

Figure 5 file operation process

 

The main code for editing files and renaming files is as follows:

// edit file

if ($_POST['do'] == 'doeditfile')    

{

if (!empty($_POST['editfilename']))

{

$filename="$editfilename";

@$fp=fopen("$filename","w");

echo $msg=@fwrite($fp,$_POST['filecontent']) ?

"Write file successfully!" : "Write failed!";

@fclose($fp);

}

else

{

echo "Please enter the name of the file you want to edit!";

}

}

// Edit file properties

elseif ($_POST['do'] == 'editfileperm')

{

if (!empty($_POST['fileperm']))

{

$fileperm=base_convert($_POST['fileperm'],8,10);

echo (@chmod($dir."/".$file,$fileperm)) ? "Attribute modified successfully!" : "Modification failed!";

echo "file".$file." The modified property is: ".substr(base_convert(@fileperms($dir."/".$file),10,8),

-4);

}

else

{

echo "Please enter the property you want to set!";

}

}

4.3 Command operation module

Command operation is the interpretation and execution of various SHELL commands, which are mainly executed through functions such as system and passthru of php. Process operations and system operations can be performed in this module. Note that the web mode is used and interactive shell commands cannot be executed. In the design, use a form to get the commond variable, execute system("sudo $commond") after submitting to the system function, and return the result.

The command operation flow is shown in Figure 6

 

Figure 6 command operation flow

Part of the code is as follows:

if (!empty($_POST['command']))

{

if ($execfunc=="system")

{

system("sudo ".$_POST['command']);

}

elseif ($execfunc=="passthru")

{

passthru("sudo ".$_POST['command']);

}

elseif ($execfunc=="exec")

{

$result = exec("sudo ".$_POST['command']);

echo $result;

}

elseif ($execfunc=="shell_exec")

{

$result=shell_exec("sudo ".$_POST['command']);

echo $result;

}

elseif ($execfunc=="popen")

{

$pp = popen("sudo ".$_POST['command'], 'r');

$read = fread($pp, 2096);

echo $read;

pclose($pp);

}

elseif ($execfunc=="wscript")

{

$wsh = new COM('W'.'Scr'.'ip'.'t.she'.'ll') or

die("PHP Create COM WSHSHELL failed");

$exec = $wsh->exec

("cm"."d.e"."xe /c "."sudo ".$_POST['command']."");

$stdout = $exec->StdOut();

$stroutput = $stdout->ReadAll();

echo $stroutput;

}

else

{

system("sudo ".$_POST['command']);

}

}

4.4 Process operation module

Process operations mainly include viewing or terminating running processes, viewing the list of enabled services, managing the enabled services, viewing all running processes in the current system, and performing related operations on the processes. This is mainly obtained by executing ps - aux to obtain the process list, and then express it in a table, and can kill each process.

The process operation flow is shown in Figure 7:

 

Figure 7 process operation flow

The main code is as follows:

if ($_GET['action'] == "process")

{

if(!$win) {$handler = "ps -aux".($grep?"

| grep '".addslashes($grep)."'":"");}

else {$handler = "tasklist";}

$ret = myshellexec($handler);

if(!$ret) {echo "Can't execute \"".$handler."\"!";}

else

{

if(empty($processes_sort))

{$processes_sort = $sort_default;}

$parsesort = parsesort($processes_sort);

if (!is_numeric($parsesort[0])) {$parsesort[0] = 0;}

$k = $parsesort[0];

if($parsesort[1] != "a")

{

$y="<a href=\"".$surl."action=".$dspact."&d=".

urlencode($d)."&processes_sort=".$k."a\">

<img src=\"".$surl."action=img&img=

sort_desc\"height=\"9\"width=\"14\" order=\"0\"></a>";

}

else

{

$y="<a href=\"".$surl."action=".$dspact."&d=".

urlencode($d)."&processes_sort=".$k."d\">

<img src=\"".$surl."action=img&img=

sort_asc\"height=\"9\" width=\"14\" border=\"0\"></a>";

}

$right = htmlspecialchars($right);

if (!$win)

{

if ($pid)

{

if (is_null($sig)) {$sig = 9;}

echo "Sending signal ".$sig." to #".$pid."... ";

if (posix_kill($pid,$sig)) {echo "OK.";}

else {echo "ERROR.";}

}

}

}

}

4.5 System Operation Module

System operations mainly include shutting down or restarting, changing passwords, viewing system information, managing users and

group, manage packages. This is mainly by changing the permissions of Apache and the shell that executes the command, and putting

Apache is added to the sudoers file to become a member that can execute the sudo command.

For shutdown and restart, the administrator can click the Shutdown and Reboot buttons to call the system function to execute the built-in shutdown and restart commands, or enter other shutdown or restart commands in the form and run them.

View system information, judge the submitted command through switch, and call the system function to execute built-in commands such as uname –a, fdisk –l, etc., including viewing CPU information, viewing partition information, and viewing the kernel.

Manage users and groups, you can view the users and groups owned by the system, and submit through a simple form to add or delete users or groups.

The system operation process is shown in Figure 8:

 

Figure 8 System operation flow

The main code for viewing system information and managing users and groups is as follows:

//View system information

switch($_POST['info'])

{

case "CPU Info":

$exec="sudo cat /proc/cpuinfo";break;

case "Disk Info":

$exec="sudo fdisk -l";break;

case "Kernel Version":

$exec="sudo uname -a";

}

if($exec) { system($exec);}

//Manage users and groups

$commond="sudo groupdel ".$_POST['group'];

echo $commond;

if($commond)  { system($commond); }

$commond="sudo groupadd ".$_POST['group'];

echo $commond;

if($commond)  { system($commond); }

switch($_POST['passmode'])

{

case 0:

$passwd="";break;

case 1:

$passwd=" -p ".$_POST['encpass'];

}

if(!$_POST['home'])

{

$home=" -d ".$_POST['home'];

}

$user=$_POST['user'];

$uid=" -u ".$_POST['uid'];

$shell=" -s ".$_POST['shell'];

$commond="sudo useradd ".$_POST['user']." -d ".$_POST['home']." -s ".$_POST['shell']." -u ".$_POST['uid']." -p ".$_POST['encpass'];

echo $commond;

if($commond)  { system($commond); }

$commond="sudo userdel ".$_POST['user'];

echo $commond;

if($commond)  { system($commond); }

4.6 Network Operation Module

Network operations mainly include managing Apache server, managing PHP server, managing MySQL server, managing SSH server, managing DHCP server, viewing network parameters, and configuring network parameters.

Viewing network parameters mainly includes viewing network connection status, routing table, network card interface information, network statistics, arp temporary storage information, and basic network configuration parameters.

Configuring network parameters mainly includes configuring basic network parameters, adding and deleting routes.

Managing PHP servers mainly includes viewing PHP environment variables, PHP information, and configuring PHP.

Managing the Apache server mainly includes stopping the server and configuring the server.

Manage MySQL server mainly includes database query and backup, server start, stop and restart.

Managing an SSH server mainly includes starting, stopping, and restarting the server.

Managing the DHCP server mainly includes starting, stopping, and restarting the server.

The process operation flow is shown in Figure 9:

 

Figure 9 Network operation process

The main code for configuring network parameters is as follows:

switch($_POST['config'])

{

case ConfigIP:

$exec="ifconfig eth0 ".$ip." netmask ".$mask." up";

$exec1="route add default gw ".$gw;

$flag=1;break;

case ConfigDNS:

$dns=1;break;

case AddHostRoute:

$exec="route add -host ".$host." gw ".$rgw;break;

case AddNetRoute:

$exec="route add -net ".$netroute." netmask ".

$nmask." gw ".$nrgw; break;

case DelHostRoute:

$exec="route del -host ".$dhost." gw ".$drgw;break;

case DelNetRoute:

$exec="route del -net ".$dnetroute." netmask ".$dnmask."

gw ".$dnrgw; break;

}

if($exec)

{

system("sudo $exec",&$ret);

if(!$ret)

echo "Changed successfully\n";

else

echo "Changed unsuccessfully\n";

}

if($flag)

{

system("sudo $exec1",&$ret1);

$flag=0;

if(!$ret1)

echo "Getway Changed successfully\n";

else

echo "Getway Changed unsuccessfully\n";

}

if($dns)

{

$fd=fopen("/etc/resolv.conf", "w+");

if ($fd)

{

if($dns1)

fwrite($fd, "nameserver $dns1\n");

if($dns2)

fwrite($fd, "nameserver $dns2\n");

if($dns3)

fwrite($fd, "nameserver $dns3\n");

}

else

echo "open file error!\n";

$dns=0;

if(!$dns1 && !$dns2 && !$dns3)

echo "DNS has not changed!";

else

echo "DNS has changed!";

fclose($fd);

5 system test

5.1 Secure Access Module

When the user logs in on the remote host, the following figure will appear for the user to enter the user name and password. After that, the PHP verification page will appear, and another password needs to be entered again. When the user clicks the logout button, the user will lose the management page and return to the PHP authentication page. When the user needs to log in to the remote server again for management, he can enter the password to log in for management. The secure access module works fine.

The login interface is shown in Figure 10:

 

Figure 10 Login

5.2 File Operation Module

After the user logs in to the remote server and enters the file operation module, he can operate the file system of the server. After testing, you can download files, display files and directories, etc. normally, but you need to set some permissions on the server side when editing and uploading files.

The file operation interface is shown in Figure 11:

 

Figure 11 File operation

5.3 Command operation module

After the user logs in to the remote server and enters the command operation module, he can enter commands to perform various operations. After testing, the system can run well for non-interactive commands, but for interactive commands, the system sometimes cannot run, sometimes it cannot run correctly, and sometimes it takes a long time.

5.4 Process operation module

After the user logs in to the remote server and enters the process operation module, he can operate the process running on the server. After testing, the running process can be correctly displayed in the form of a table, and there is a KILL button on the far right of each item in the table. When you need to kill a certain process, you can click this button. The module can run normally.

5.5 System Operation Module

When the user logs in to the remote server and enters the system operation module, he can perform various operations on the server.

System management operations. After testing, it can shut down or restart normally, change passwords, view system information, manage users and groups, and manage software packages. But this is just simple system management, and it doesn't involve much in complex system management, or it is only a small part of the implementation.

5.6 Network Operation Module

 After the user logs in to the remote server and enters the network operation module, he can view and configure the network parameters of the server. After testing, you can view network connection status, routing table, network card interface information, network statistics, arp temporary storage information, and basic network configuration parameters. You can configure basic network parameters, add and delete routes. You can view PHP environment variables, PHP information, and configure PHP. You can stop the Apache server and configure the Apache server. Can manage MySQL server including database query and backup, server start, stop and restart. You can manage the SSH server including starting, stopping and restarting the server. You can manage the DHCP server including starting, stopping and restarting the server. But this is only a small part of the simple implementation of network operations, and some complex operations have not been implemented.

Check the network parameter interface as shown in Figure 12:

 

Figure 12 View network parameters

in conclusion

Through the research of this topic, I understand the operating mechanism and technology of B/S structure software, and learn many principles and design processes of software engineering. Although the remote management system realizes file operations, process operations, command operations, system operations and network operations, these are only preliminary implementations, and there are still many deficiencies, such as the setting of permissions, incompleteness of some network operations, and some The operation has not yet been implemented. Others can implement it according to our design ideas.

The remote management system based on the web management Linux system is a relatively complicated problem, but it is also a very challenging subject, and it is also a very practical subject. Such a remote management system can save a lot of time and work for system administrators, making system management more convenient, easier and more friendly.

The research of this topic refers to the design pattern and development process of other people's successful software development. In the study of this topic, I learned that every stage of software development, such as requirements analysis, outline design, detailed design, system coding, and system testing, is very important, especially requirements analysis and outline design. These two stages directly It is related to the quality of the entire system, directly affects the future development, and also corrected many of my misunderstandings about software development. For example, I used to think that software development is coding.

ginsengBibliography _

[1] Evi Nermeth. UNIX System Management Technical Manual [M]. Beijing: People's Posts and Telecommunications Press, 2002.

[2] Rasmus Lerdorf, Kevin Tatroe. PH programming [M]. Beijing: China Electric Power Press, 2003.

[3] Guo Jinfeng, Lin Yu. PHP&MySql Web Network Programming [M]. Beijing: People's Posts and Telecommunications Press, 2001.

[4] Ning Lei, Zhou Wei. Linux Network and Security Management [M]. Beijing: People's Posts and Telecommunications Press, 2001.

[5] Zhao Qizhi. PHP 4+MySQL complete self-study program [M]. Beijing China Railway Press, 2001.

[6] Cox. Red Hat Linux System Administrator's Manual [M]. Beijing: Mechanical Industry Press, 2001.

[7] Leon Atkinson. PHP 4 Core Programming [M]. Beijing: China Water Conservancy and Hydropower Press, 2001.

[8] Tobias Ratschiller. PHP 4.0 Web Development Technical Guide [M]. Beijing: Mechanical Industry Press, 2001.

thanks

This article was completed under the enthusiastic care and guidance of Mr. Fang Rui. His profound knowledge and rigorous academic style have benefited me a lot and played a great role in successfully completing this project. Here I would like to express my heartfelt thanks to him!

Thanks to the Internet for its help in the early stage of the project research. With the help of the Internet, the project can be carried out very well, and it has a very good start! During the process of completing the thesis, I also received enthusiastic help from other teachers and many classmates, and I would like to express my deep gratitude to them!

Finally, I would like to express my heartfelt thanks to all the experts and teachers who reviewed this article in the midst of their busy schedules!

 

Pay attention to the blogger, the next article is more exciting

One-click three-in-one! ! !

One-click three-in-one! ! !

One-click three-in-one! ! !
Thanks for the one-click triple! ! !

Guess you like

Origin blog.csdn.net/m0_56073435/article/details/131476412