linux中控操作相关

1、首先生成无密码登陆密钥 一般使用rsa

2、编写shell脚本

work_dir=$(pwd)
   ssh -p${port} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${host_prefix}$1

3、远程拷贝

  

work_dir=$(pwd)
for i in {2..9}
do
  scp -P20755 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r $1 ¥{host_prefix}$i:$2
  echo
done

4、远程执行命令

work_dir=$(pwd)
for i in {1..9}
do
   ssh -p20755 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ¥{host_prefix}$i "cd $work_dir; $@"
done

 

posted @ 2017-04-12 11:22  wq920  阅读(415)  评论(0编辑  收藏  举报