よく忘れるので備忘録
1 2 3 4 5 6 7 8 9 10 11 12 | #!/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 |