Create two scripts in the system bin directory, respectively, Pssh tssh
Pssh
#!/usr/bin/expect-fSet IP [lindex$argv 0]set Port [lindex$argv 1]set Password [lindex$argv 2]set TimeoutTenspawn ssh [email protected]$ip-P$portExpect {"*yes/no"{Send "yes\r"; Exp_continue}"*password:"{Send "$password \ r"}}interact
Tssh
#!/bin/shEcho"here is a list of all your servers"Echo"1.A Server 192.168.100.11"Echo"2.B Server 192.168.100.12"Echo"3.C Server 192.168.100.13"Echo"0. Temporarily do not want to log in"Echo"Please enter the corresponding number, select the server you want to log in: \c"Readinputtest$input=0 Case$inputinch1) Pssh192.168.100.11 A 123456;;2) Pssh192.168.100.12 Aadmin;;3) Pssh192.168.100.13 Aroot;; Esac
Remember to add executable permissions to the script
Then execute TSSH on the terminal and the following results appear
Here is a list of all your servers
1.A Server 192.168.100.11
2.B Server 192.168.100.12
3.C Server 192.168.100.13
0. Temporarily do not want to log in
Please enter the corresponding number, select the server you want to log in: 1
Spawn ssh [email protected]-p22
CentOS Release 6.8 (Final)
Kernel \ r on an \m
[email protected] ' s password:
Last Login:thu 18:34:58 from 192.168.100.2
Welcome to Aliyun Elastic Compute service!
[Email protected] ~]#
Choose login SSH using shell scripting custom implementation