FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


Sidebar


Top     SiteMap

Manager Server

Target Server

$FHHOME/bin/xxx.sh | xxxx.exp













.

fhscripts:fh:fhssh.sh.html



This is an old revision of the document!



FastHandle Scripts

fhlogin.sh - auto login script

Operation

$ fhlogin.sh xxxxxx


Script

#!/bin/bash
#=====================================================================
# fhlogin.sh
# 
# How to use
#    fhlogin.sh  xx.xx.xx.xx
#=====================================================================

if [ -z $1 ]; then
    echo 'Error:  $1 argument is null'
    exit 1
fi

HOST=$1

# ------------------------------------------
SSH_PASS () {

expect -c "
set timeout 5
spawn ssh  ${USER}@${HOST}
expect \"assword:\"
send \"$PASSWD\r\"
interact
"
}

# ------------------------------------------
SSH_KEY_NOPASS () {

expect -c "
set timeout 5
spawn ssh -i ${KEY} ${USER}@${HOST}
interact
"
}

# ------------------------------------------
SSH_KEY_PASS () {

expect -c "
set timeout 5
spawn ssh -i ${KEY} ${USER}@${HOST}
expect \"assword:\"
send \"$PASSWD\r\"
interact
"
}

cat <<MENU
=====================================================================
ghlogin.sh
---------------------------------------------------------------
   1) production  user01   password atuh
   2) stating  user01
   3) test  user01
   q) quit
=====================================================================
MENU

echo -n -e "\t >"
read NUM
case ${NUM} in
  1) USER=user01
     PASSWD=testpass
     SSH_PASS
    ;;
  2) USER=user01
     PASSWD=testpass
     KEY=/home/xxx/.ssh/xxxx.pub
     SSH_KEY_NOPASS
    ;;
  3) USER=user01
     PASSWD=testpass
     SSH_KEY_PASS
    ;;
  q|Q) exit
     ;;
  *) echo "exit : selection is missed."
     exit
     ;;
esac








FastHandle Scripts



fhscripts/fh/fhssh.sh.html.1511708858.txt.gz ยท Last modified: 2017/11/27 00:07 by kurihara