#!/usr/bin/expect set IP 127.0.0.1 set USER root set PASSWORD 123456 spawn ssh $USER@$IP expect { "*yes/no" { send "yes\r"; exp_continue} "*assword:" { send "$PASSWORD\r" } } interact