Background
Always need to log on to the online service to solve various problems, such as:
Remote Login online log machine view PHP error log, Mysql error log, etc.
Log in QA tester to check if the code is properly released and the configuration is correct
Log on to a personal development machine
But the company's servers are required to log on through the springboard, each login on the machine need to log in first to the springboard, and then login to the target machine, very cumbersome, and must remember to live the target machine IP or machine name to log on as soon as possible, or else have a meal check ...
So I got a gadget, a quick login (in fact, a little script written a few years ago, recently upgraded), and shared it with everyone. The function probably includes:
Customizing shortcut logon methods for remote machines
View all configured shortcuts
Support for two kinds of scenarios for springboard and non-springboard login
For any authorized machine, you can log in directly to a single command
Can specify any account login online server
In short, it is quite convenient, simple gadgets, open to everyone, you may also use.
One, the tool downloads
Baidu Search Go tool: Go.zip
II. Configuration & Deployment
1, save the file to a fixed directory
CP ~/downloads/go ~/documents/tools/
2, modify the permissions
chmod 0755 ~/documents/tools/go
3, configure to the environment variable
Cd/usr/bin
Ln-s ~/documents/tools/go Go
4, modify the configuration
Vim ~/documents/tools/go
Note: The contents to be modified are:
Username: for landing Board
Default_user: Default has this account logged into the online machine
Server_list: Custom Login Shortcuts
Third, the use
1. View Help
Go-h
go -list
3, the default user login to a line machine
go syq-fe03
4, to specify the user login Newlab machine
go newlab xianliezhao
5, any one has the permission machine, but did not configure the shortcut
go 172.16.0.31 work
6, about the configuration & login non-springboard machine (such as my Aliyun machine)
go aliyun
Five, the foot source code
#! /bin/sh ################################################################## # This tool is used to quickly log on to the online machine # author:xianliezhao@meilishuo.com ################################################################## # Your name, Used to log on to the springboard Username= "Xianliezhao" # By default, log on to the online machine default_user= "Work" to define the machine shortcut server_list= (#---------------------- ------------------------------------------------------------------------------# "Shortcut machine name/IP need springboard (default is 1: What permissions to Login (default is: $default _user) "#----------------------------------------------------------------------------- -----------------------"Syq-fe01 syq-bizfe-01" "Syq-fe02 syq-bizfe-02" "Syq-fe03 syq-bizfe- "" "" Syq-fe04 syq-bizfe-04 "" Dfz-fe01 dfz-bizfe-01 "" Dfz-fe02 dfz-bizfe-02 "" Dfz-fe03
Dfz-bizfe-03 "" "Dfz-fe04 dfz-bizfe-04" "Dfz-fe05 dfz-bizfe-05" "Dfz-fe06 dfz-bizfe-06" "Dfz-fe07 dfz-bizfe-07" "Dfz-fe08 dfz-bizfe-08" "DFz-snake01 dfz-bizsnake-01 "" Dfz-snake02 dfz-bizsnake-02 "dfz-snake03 dfz-bizsnake-03" "Dfz-doota01 Dfz-dootafe-01 "" "Dfz-doota02 dfz-dootafe-02" "Dfz-doota03 dfz-dootafe-03" "Aliyun Www.baidufe
. com 0 root ") # using Help assistance () {echo Telnet tool: Version 1.0 usage:" 1 ": Go machine Name [login account] Usage 1: Login By default with work permissions Newlab----> Go newlab usage 2: Login with rd permission Newlab----> Go Newla
B RD Usage 3: Login with personal account Newlab----> Go newlab Xianliezhao "2": View all Machine shortcuts: go-list \ n "Exit 1} # View all Shortcuts show_list () {echo \ n You can use shortcuts to log on to the following server, such as: Go Newlab rdol\n" echo "+ ------------------------------------------------------------------------------+ "for (i=0;i<${#server_list [* ]};i=i+5));d o a= ' echo ${server_list[$i +0]} | awk ' {print} ' b= ' echo ${server_list[$i +1]} | awk ' {print '} ' c= ' echo ${server_list[$i +2]} | awk ' {print} ' d= ' echo ${server_list[$i +3]} | awk ' {print} ' e= ' echo ${server_list[$i +4]} |
awk ' {print} ' # format output printf "%-1s%-13s%-1s%-13s%-1s%-13s%-1s%-13s%-1s%-12s%-1s\n" \ \| ${a:-'} \| ${b:-'} \| ${c:-'} \| ${d:-'} \|
${e:-'} \| Done echo "+------------------------------------------------------------------------------+\n"} # telnet Remote_login () {# The default target machine is the host=$1 # Springboard proxy= "@osys11. meilishuo.com-t ssh" # If the second parameter is specified, the specified account login if ["$"!= ""];then default_user=$2 Fi # If the default logon user is Rdol, switch the user if [$default osys11 = =] on the _user machine.
Rdol "];then proxy= $proxy" rdol@osys11-t ssh "; Fi # from Server_list query if there is a predetermined shortcut for key in ${!server_list[*]}; Do a= ' echo ${server_list[$key]} | awk ' {print '} ' # shortcuts b= ' echo ${server_list[$key]} | awk ' {print $} ' # machine name/IP c= ' echo ${server_list[$key]} | Does awk ' {print $} ' # need to log on through the Springboard d= ' echo ${server_list[$key]} |
awk ' {print $} ' # login username if ["$host" = "$A"];then host= $B;
If ["$C" = = "0"];then proxy= "";
fi if [!-Z $D];then default_user= "" Username= $D fi
Break Fi Done # login target machine ssh $username $proxy$default_user@ $host} Clear # no parameters specified, or the parameter is-h | --help, the use Help if [["$ = =" "| |" appears). $ "="-H "| |
"$" = = "--help"]];then help;
# View all Shortcuts elif ["$" = "-list"];then show_list;
# Execute login Else Remote_login $; Fi