shell编程_SSH和EOF结合
ssh和EOF结合使用案例代码,如下。
for ip in root@192.168.11.1 do ssh -T $ip <<MKDIREND cp /app/File_Out/ta_hk_notify.txt /File_In/ exit MKDIREND done
上面代码含义,ssh和EOF结合实现本地服务器登陆远程服务器,在远程服务器上执行shell命令。
这里需要指出场景,使用该段代码时,本地服务器和远程服务器之间配置了免密。同时解释ssh中的参数-T的含义是登录远程主机之后,远程主机不需要分配shell终端。
语法格式,如下。
ssh user@host <<'ENDSSH' #commands to run on remote host ENDSSH
stack overflow 相关问题的提问https://serverfault.com/questions/215756/how-do-i-run-a-local-bash-script-on-remote-machines-via-ssh
posted on 2020-11-30 21:26 XiaoXiaoli 阅读(2833) 评论(0) 收藏 举报