Batch deploy Linux servers using reverse CT

Source: Internet
Author: User
Trusted CT is a software tool used in Unix systems for automated control and testing. It is made by DonLibes and is an extension of the Tcl scripting language. It is used in interactive software such as telnet, ftp, Passwd, fsck, rlogin, tip, and ssh. This tool uses Unix pseudo terminals to package its sub-processes, allowing any program to access the terminal for automatic control.

Trusted CT is a software tool used in Unix systems for automated control and testing. It is made by Don Libes and is an extension of the Tcl scripting language. It is used in interactive software such as teLnEt,Ftp, Passwd,Fsck, Rlogin, tip, ssh, and so on. The tool uses Unix pseudo terminals to package its sub-processes, allowing any program to access the terminal for automatic control. It can also use Tk tools to package interaction programs in the X11 graphic user interface.

Involved files:
1: login.ExP
2:Passwd. Txt
3: CT. sh
Objective To execute the test. sh file in batches

1: login. exp

#!/usr/bin/expect -fset ipaddress [lindex $argv 0]set passwd [lindex $argv 1]set timeout 30spawn ssh root@$ipaddressexpect {"yes/no" { send "yes\r";exp_continue }"password:" { send "$passwd\r" }}expect "]*"send "wget http://lazyom.com/test.sh \r"send "sh test.sh\r"send "exit\r"expect eof

2: passwd.txt

IP    PASSWD

3: CT. sh

#!/bin/bashfor i in `awk '{print $1}' passwd.txt`doj=`awk -v I="$i" '{if(I==$1)print $2}' passwd.txt`expect /root/bin/expect/login.exp $i $jdone

Set timeout 30
Set the timeout value in seconds.

Spawn is the Internal Audit CT that can be executed only after entering the audit CT EnvironmentCommandThe spawn command cannot be found if you have not installed the secondary CT or run it directly in the default SHELL. Therefore, do not use"WhichSpawn and other commands to find the spawn command. For example, in windows, dir is an internal command that comes with shell. You cannot find an executable file of dir.com or dir.exe. Its main function is to add a shell to the ssh running process to transmit interactive commands.

Login CT "password :"
The secondary CT command is also an internal command of the secondary CT. The shell command of the secondary CT is the same as that of the Internal Command, www. linuxIdC.com is not a function. This command is used to determine whether the output result contains a string of "password:". If yes, return immediately; otherwise, return after a period of time, the waiting duration is the last 30 seconds.

Send "nopasswd \ r"
The interaction is performed here, which is equivalent to the password input.
Tip: do not add "\ r" to the end of the command string. If an exception occurs, check it.

Interact
After the execution is complete, the interaction status is maintained, and the control is handed over to the console. At this time, you can perform manual operations. If this statement is not entered, the system will exit after logon, instead of staying on the remote terminal. If you log on and run a command to exit, you can change it to [cT eof 〕

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.