Build an SSH Springboard machine
Environment Introduction:
[Email protected] ~]# cat/etc/redhat-release CentOS release 6.6 (Final) [[email protected] ~]# uname-r2.6.32-504.el6.x86 _64
Prepare 2-3 virtual machines, at least 2 units.
1. Create a springboard machine user on all machines
[[email protected] ~]# useradd tb[[email protected] ~]# echo "123.com" |PASSWD--stdin TB
2. Create a key on a springboard machine
[[email protected] ~]# su-tb[[email protected] ~]# ssh-keygen-t dsa-p-F ~/.SSH/ID_DSA
Copy the generated key to a machine that needs to be logged on through a springboard machine.
[Email protected] ~]# ssh-copy-id-i ssh/id_dsa.pub "-p [email protected]" [[email protected] ~]# ssh-copy-id-i. ssh/ Id_dsa.pub "-p [email protected]" [[email protected] ~]# ssh-copy-id-i. ssh/id_dsa.pub "-p [email protected]"
3. Create a Springboard machine script
[[email protected] ~]# cd /server/scripts[[email protected] ~]# vim Tiaoban.sh#!/bin/bashfunction trapper () { trap " int quit tstp term hup}function menu () { cat <<-eof <== is preceded by a minus sign ========= host list========== 1) 192.168.75.141 2) 192.168.75.140 3) 192.168.75.139 4) exit============================= eof <===eof Front is a tab key, not 4 spaces. }function host () { case "$" in 1) ssh [email protected] ;; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;2) ssh [email protected] ;; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;3) ssh [email protected] ;; 4|*) exit ;; esac}function main () { while true do trapper clear menu read -p "Please select:" num host $num done}main:wq Keep out
4. Add Login System Load Script
[[email protected] ~]# cd/etc/profile.d/[[email protected] ~]# vim tiaoban.sh #添加如下内容 [$UID-ne 0] && [$UID-N e-]&&. /server/scripts/tiaoban.sh# The root user uid is known as the 0,oldboy user uid of 500, these users do not enter the springboard system.
5. Test below. Use Xshell to log in to the springboard machine.
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/8C/AA/wKioL1h0TnLyrpJWAACaN_2xpYY438.png "style=" float : none; "title=" Test 01.png "alt=" Wkiol1h0tnlyrpjwaacan_2xpyy438.png "/>
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/8C/AE/wKiom1h0TnPQx9V8AAChAvAlx8k258.png "style=" float : none; "title=" Test 02.png "alt=" Wkiom1h0tnpqx9v8aachavalx8k258.png "/>
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/8C/AA/wKioL1h0TnPwQkceAAAWSU3XBew030.png "style=" float : none; "title=" Test 03.png "alt=" Wkiol1h0tnpwqkceaaawsu3xbew030.png "/>
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/8C/AE/wKiom1h0TnSR6lVWAABO_WugR_M070.png "style=" float : none; "title=" Test 04.png "alt=" Wkiom1h0tnsr6lvwaabo_wugr_m070.png "/>
This article is from "Xiao Zeng" blog, please be sure to keep this source http://zengxin.blog.51cto.com/6098070/1890655
Build an SSH Springboard machine