#!/bin/bash. /etc/init.d/functionsfunction add_user () { jumper= "$" useradd ${jumper} echo 123456 | passwd --stdin ${jumper} >/dev/ null 2>&1 if [ ' grep -o $jumper /etc/passwd | wc -l ' -gt 1 ] then action "Add user ${jumper} success " /bin/true else action "Add user ${jumper} success failure" /bin/false exit 0 fi su ${jumper} -c "ssh-keygen -t dsa -p " -f ~/.ssh/id_dsa > /dev/null 2>&1 " if [ $? -eq 0 ] then &nbSp; action "Create ssh pub key success" /bin/true else action "Create ssh pub key failure" /bin/false fi}add_user $*for n in 7 8 do /usr/bin/expect /server/ Scripts/fenfa_key.exp /home/${jumper}/.ssh/id_dsa.pub ${jumper} 11.0.0.${n} >/dev/null  2>&1        IF [ $? -EQ 0 ] then action "Fenfa ssh pub key to 11.0.0.${n} success " /bin/true else action "fenfa ssh Pub key to 11.0.0.${n} failure " /bin/false fidone
#!/usr/bin/expectif {$ARGC! = 3} {puts "usage:expect $argv 0 Sshkey User host" exit} #define VarSet Sshkey [lindex $argv 0]set User [lindex $argv 1]set host [lindex $argv 2]set password "123456" Spawn ssh-copy-id-i $sshkey [email Protected] $hostexpect {"yes/no" {send "yes\r"; exp_continue} "*password" {send "$password \ r"}}expect E Of
#!/bin/bashfunction traper () { trap ' INT Quit tstp term hup}function menu () { cat <<-EOF================Host List============== 1) 11.0.0.7 2) 10.0.0.8 3) Exit================host end=============== eof} Function host () {user=test09 case "$" in &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;1) ssh [email protected] ;; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;2) ssh [email protected] ;; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;3) &NBSP;&NBSP;&NBSP;&NBSP;EXIT&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;ESAC} Function main () { while true do traper clear menu read -p ' Pls input your choice: ' num host $num done}main
cat/etc/profile.d/jump.sh #!/bin/bash[$UID-ne 0] && [$USER! = "Zihang"] &&/bin/bash/server/scripts/ tiaoban.sh
======================== deficiency, please advise =========================
This article is from the "Lost in Linux" blog, please be sure to keep this source http://zihang.blog.51cto.com/158746/1913476
Shell implements a springboard machine