-
-
Save moreta/1780983 to your computer and use it in GitHub Desktop.
sssh(ssh自動ログイン)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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