expect_ssh_key_with_passphrase.sh
#! /bin/bash
host=xxx.xxx.xxx.xxx
login_name=hoge
key=/xxxx/xxxx/xxxx/id_rsa
passphrase=xxxxxxxx
if [ -z `ssh-add -l | grep $key | awk '{print $3}'` ]; then
expect -c "
set timeout -1
spawn ssh-add $key
expect \"Enter passphrase for $key:\"
send \"$passphrase\n\"
interact
"
fi
ssh -l $login_name -i $key $host