FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


fhscripts:fh:fhssh.sh.html



Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
fhscripts:fh:fhssh.sh.html [2017/11/25 00:45]
kurihara ↷ Page moved from scripts:fhlogin.sh.html to fhscripts:fhlogin.sh.html
fhscripts:fh:fhssh.sh.html [2019/02/12 23:19]
kurihara
Line 1: Line 1:
-~~NOTOC~~ 
 [[:index.html#FastHandle Scripts|FastHandle Scripts]] [[:index.html#FastHandle Scripts|FastHandle Scripts]]
-====== fhlogin.sh ======+====== SSH Auto Login Script without Password (fhssh.sh)======
  
 +$FHHOME/bin/fhssh.sh
  
 +{{INLINETOC}}
 +\\
  
-===== Operation =====+ 
 +===== fhssh.sh Operation =====
 <sxh bash toolbar:false gutter:false> <sxh bash toolbar:false gutter:false>
-fhlogin.sh xxxxxx+fhssh.sh -H 192.168.0.10  auth.pro 
 +$ fhssh.sh -H 192.168.0.11  auth.stg 
 +</sxh> 
 + 
 +== Application Example == 
 +<sxh bash toolbar:false gutter:false> 
 +~]$ fhssh.sh -l 
 +How to use 
 +  fhssh.sh -H x.x.x.x  auth.pro 
 +  fhssh.sh -H x.x.x.x  auth.stg 
 +  fhssh.sh -H x.x.x.x  auth.dev 
 +  fhssh.sh -H x.x.x.x  auth.srx_pro 
 +  fhssh.sh -H x.x.x.x  auth.srx_dev 
 +~]$
 </sxh> </sxh>
  
 \\ \\
-===== Script =====+===== fhssh.sh ===== 
 + 
 +$FHHOME/bin/fhssh.sh
  
 <sxh bash toolbar:false gutter:false> <sxh bash toolbar:false gutter:false>
 #!/bin/bash #!/bin/bash
 #===================================================================== #=====================================================================
-fhlogin.sh +fhssh.sh 
-+#
 # How to use # How to use
-#    fhlogin.sh  xx.xx.xx.xx+#    fhssh.sh  -l   <- list command 
 +#    fhssh.sh  -h 
 +#    fhssh.sh  -H xx.xx.xx.xx  auth.pro 
 +#    fhssh.sh  -H xx.xx.xx.xx  auth.stg
 #===================================================================== #=====================================================================
  
-if [ -$1 ]; then +HELP () { 
-    echo 'Error $1 argument is null'+    echo "How to use" 
 +    cat $0 |grep auth |grep ")"|grep -v "fhssh.sh" |awk -F")" {'print "  fhssh.sh -H x.x.x.x"  $1'} 
 +    exit 0 
 +
 + 
 +ERROR () { 
 +    echo "" 
 +    echo 'ERROROption is mistake' 
 +    echo "" 
 +
 + 
 +case ${1} in 
 +  -h|-l) HELP 
 +     ;; 
 +esac 
 + 
 +if [ -z ${3} ]; then 
 +    ERROR 
 +    HELP
     exit 1     exit 1
 fi fi
  
-HOST=$1+case ${1} in 
 +  -H) : 
 +    HOST=$
 +    AUTH=$3 
 +     ;; 
 +  *) : 
 +    ERROR 
 +    HELP 
 +    exit 1 
 +    ;; 
 +esac
  
-------------------------------------------+#=================================================================== 
 +
 +#===================================================================
 SSH_PASS () { SSH_PASS () {
  
Line 47: Line 98:
 set timeout 5 set timeout 5
 spawn ssh -i ${KEY} ${USER}@${HOST} spawn ssh -i ${KEY} ${USER}@${HOST}
 +expect \"$\"
 interact interact
 " "
Line 59: Line 111:
 expect \"assword:\" expect \"assword:\"
 send \"$PASSWD\r\" send \"$PASSWD\r\"
 +expect \"$\"
 +interact
 +"
 +}
 +
 +# ------------------------------------------
 +SRX () {
 +
 +expect -c "
 +set timeout 5
 +spawn ssh  ${USER}@${HOST}
 +expect \"assword:\"
 +send \"$PASSWD\r\"
 +expect \"%\"
 +send \"cli\r\"
 +expect \">\"
 +send \"show configuration | display set | no-more\"
 interact interact
 " "
 } }
  
-cat <<MENU 
-===================================================================== 
-ghlogin.sh 
---------------------------------------------------------------- 
-   1) production  user01   password atuh 
-   2) stating  user01 
-   3) test  user01 
-   q) quit 
-===================================================================== 
-MENU 
  
-echo -n -e "\t >" +case ${AUTH} in 
-read NUM +  auth.pro
-case ${NUM} in +     USER=user01
-  1) USER=user01+
      PASSWD=testpass      PASSWD=testpass
      SSH_PASS      SSH_PASS
     ;;     ;;
-  2) USER=user01+  auth.stg
 +     USER=user01
      PASSWD=testpass      PASSWD=testpass
      KEY=/home/xxx/.ssh/xxxx.pub      KEY=/home/xxx/.ssh/xxxx.pub
      SSH_KEY_NOPASS      SSH_KEY_NOPASS
     ;;     ;;
-  3) USER=user01+  auth.dev
 +     USER=user01
      PASSWD=testpass      PASSWD=testpass
      SSH_KEY_PASS      SSH_KEY_PASS
     ;;     ;;
-  q|Qexit +  auth.srx_pro: 
-     ;; +     USER=user01 
-  *echo "exit selection is missed." +     PASSWD=testpass 
-     exit +     SRX 
-     ;;+    ;; 
 +  auth.srx_dev) : 
 +     USER=user01 
 +     PASSWD=testpass 
 +     SRX 
 +    ;;
 esac esac
  
Line 104: Line 169:
 \\ \\
 <WRAP box 90%> <WRAP box 90%>
-<catlist -noAddPageButton -smallHead -sortAscending>+<catlist ..: -noAddPageButton -smallHead -sortAscending  -sortAscending>
 </WRAP> </WRAP>
  


fhscripts/fh/fhssh.sh.html.txt · Last modified: 2019/02/12 23:20 by kurihara