よく忘れるので備忘録
#!/bin/bash my_ssh(){ /usr/bin/expect << Eof set timeout -1 spawn /usr/bin/ssh -o stricthostkeychecking=no root@hostname bash /path/to/script.sh match_max 100000 expect -exact "root@hostname's password: " send -- "password\r" expect eof Eof } my_ssh