ssh到远程执行命令并返回

假设有三台机器 host1,host2,host3,host1能免密登录其他两台。要在第一台的机器里面写一个脚本分别删除每台机器的/root/test.txt

rm -rf /root/test.txt
ssh host2 <<eeooff
rm -rf /root/test.txt
exit
eeooff
ssh host3 <<eeooff
rm -rf /root/test.txt
exit
eeooff
原文地址:https://www.cnblogs.com/boshen-hzb/p/8310212.html