expect <<EOF
set timeout 10
spawn ssh $user@$ip
expect {
"yes/no" { send "yes
";exp_continue }
"password" { send "$password
" }
}
expect "]#" { send "useradd hehe
" }
expect "]#" { send "echo rrr|passwd --stdin hehe
" }
expect "]#" { send "exit
" } expect eof
EOF