Skip to content

Instantly share code, notes, and snippets.

@moreta
Created February 9, 2012 16:39
Show Gist options
  • Save moreta/1780983 to your computer and use it in GitHub Desktop.
Save moreta/1780983 to your computer and use it in GitHub Desktop.
sssh(ssh自動ログイン)
#!/bin/sh
# 実行例1:sssh を実行すると ~/bin/server_list の一覧からserver選択して自動ssh接続
# 実行例2:sssh $server を実行すると ssh $ssh_user@$server を実行する
ssh_user="ssh user"
ssh_pass="ssh password"
ssh_login(){
if [ $# -ne 1 ]; then
echo 'usage: ssh_login $server'
exit
fi
expect -c "
spawn ssh $ssh_user@$1
expect {
\"Are you sure you want to continue connecting (yes/no)?\" {
send \"yes\r\"
expect \"password:\"
send \"$ssh_pass\r\"
} \"$ssh_user@$1's password:\" {
send \"$ssh_pass\r\"
}
}
interact
"
}
if [ $1 ];then
ssh_login $1
else
select server in `cat ~/bin/server_list`
do
ssh_login $server
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment