[sshpass] ssh 자동로그인 툴

#!/bin/bash
#
# https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/s/sshpass-1.06-1.el7.x86_64.rpm
#
LOG_FILE="test_ssh_conn.log"

test_connect() {
  echo "connecting ${2}@${1} ..."
  sshpass -p ${3} ssh -oStrictHostKeyChecking=no ${2}@${1} "exit;"

  if [ $? -eq 0 ];
  then
    echo "SUCCESS!"
  else
    echo "FAILED ${2}@${1}" >> ${LOG_FILE}
    echo "FAILED."
  fi
}

test_connect "10.10.10.49" "root" 'passwd1234'
위로 스크롤