How to securely add system users through WEB

Source: Internet
Author: User

On the Internet, we can see some solutions for directly adding system users through php. These methods are all saved in the script system's Superuser password? Security issues. The method provided here is to add a user to the mysql database through php at the front end, and set the password in the background through cron at intervals) to execute the program for adding a user. The system Superuser password is not recorded in the program, which ensures system security. The following is the background program for adding users. This program is just a rough demo program. The function is to add addornot = 0 users to the system for your reference only. The php program that adds user information to the database is omitted. The program passes

Adduserfromdb. pl #! /Usr/bin/perluse DBI; $ dbuser = "xxxx"; $ dbpasswd = "xxx"; $ db = "xxxx"; $ dbh = DBI-> connect ("DBI: mysql: $ db ", $ dbuser, $ dbpasswd); $ query =" select user, passwd from usertable where addornot = 0 "; $…… = $ dbh-> prepare ($ query); $ rv = $……-> execute or die "Can't execute the query: $…->
Errstr \ n "; while (@ row = $ th-> fetchrow_array) {# print" user = ". $ row [0]. "\ n"; # print "password = ". $ row [1]. "\ n"; @ saltchars = (.. z, .. z, 0 .. 9); srand (time | $); $ salt = $ saltchars [rand ($ # saltchars)]. $ saltchars [rand ($ # saltchars)]; # print "$ salt \ t $ row [1] \ n"; $ encrypt_passwd = crypt ($ row [1], $ salt); # print $ encrypt_passwd. "\ n"; $ add_exec = "/usr/sbin/useradd-p ". $ encrypt_passwd. "". $ row [0]; # Add parameters to useradd to control user groups, directories, logon status, shell, etc. # print $ add_exec. "\ n"; system ($ add_exec) ;}# 1; usertable: create table usertoadd (user tinytext not null, passwd tinytext not null, addornot tinyint (4) DEFAULT '0' not null );

Related Articles]

  • Web-based installation of the SAV10.1 client configuration instructions
  • Research on implementing Web-based Softswitch Configuration Management System
  • Research on Web-based Softswitch Configuration Management System Based on J2EE Technology

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.