Yum -y install expect
Vim xxx.sh
#!/usr/bin/expect
set timeout 3
set password xxxxxxx
spawn ssh root@xxxxxx
Expect {
“(yes/no)?” {
Send “yes\r”;
Expect “password:”;
Send”${password}\r”;
Exp_continue;
}
“Password:” {
Send”${password}\r”;
exp_continue;
Expect “*#”
Send “cdxxxxxxxxx\r”
Send “git pull\r”
Send “composer install\r”
Expect “yes”
Send “yes\r”
Expect “*#”
Expect eof