Skip to content

Instantly share code, notes, and snippets.

@yui0
Created August 17, 2017 05:26
Show Gist options
  • Save yui0/04f40655743da2f9dfb98bb2e4ae6b92 to your computer and use it in GitHub Desktop.
Save yui0/04f40655743da2f9dfb98bb2e4ae6b92 to your computer and use it in GitHub Desktop.
#!/bin/sh
auto_ssh() {
host=$1
id=$2
pass=$3
expect -c "
set timeout 10
spawn ssh ${id}@${host}
#expect \"Are you sure you want to continue connecting (yes/no)?\"
#send \"yes\n\"
expect \"${id}@${host}'s password:\"
send \"$pass\n\"
expect \"# \"
send \"cd /opt/work/ ; ls\n\"
interact
"
}
auto_ssh '10.10.10.10' 'root' 'password'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment