Linux systems create users in bulk

Source: Internet
Author: User

Scripting Purpose: batch creation of Linux system users

Description: to create a user's host password to write to the Ip.txt file

[email protected] scripts]# cat Ip.txt

10.165.123.0

10.172.4.150

10.165.122.77


----

#!/bin/bash

User=root

Pass=bjty01230dic


For IP in ' cat ip.txt '

Do

/usr/bin/expect-c "

Set Timeout 60

Spawn ssh [email protected] "$IP"

Set Timeout 60

Expect {

\ "*yes/n*\" {send \ "yes\r\"; Exp_continue}

\ "*assword:*\" {send \ "$pass \r\"}

}

Expect \ "\n\"

Send \ "Sleep 1\r\"

Send \ "Useradd test\r\"

Send \ "Sleep 1\r\"

Send \ "echo \ ' 1qaz2wsx\ ' | passwd--stdin test\r\ "

Expect EOF "

Done


Linux system bulk user creation

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.