Skip to content

Instantly share code, notes, and snippets.

@skatsuta
Created December 19, 2014 02:21
Show Gist options
  • Save skatsuta/efa43bd77bded188672e to your computer and use it in GitHub Desktop.
Save skatsuta/efa43bd77bded188672e to your computer and use it in GitHub Desktop.
Auto login script
#!/bin/sh
auto_ssh() {
HOST=$1
ID=$2
PASS=$3
KEY=$4
expect -c "
set timeout 10
spawn ssh ${KEY} ${ID}@${HOST}
expect \"Are you sure you want to continue connecting (yes/no)?\" {
send \"yes\n\"
expect \"${ID}@${HOST}'s password:\" {
send \"${PASS}\n\"
}
} \"${ID}@${HOST}'s password:\" {
send \"${PASS}\n\"
}
interact
"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment