老高的测试环境中机器很多,每次登录都要输入密码很烦人,下面的脚本可以批量导入公钥到指定多个ip中,使用后记得把文件删除掉!
sshpass在macos下可能不好搞定,brew因为安全问题默认不给安装,可以通过别人写好的脚本来安装,其他系统自己想办法!很简单。
brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb
TMP_PASS=yourpassword
while read SERVER
do
echo ${SERVER}
sshpass -p $TMP_PASS ssh-copy-id root@"${SERVER}"
done <<\EOF
1.1.1.1
2.2.2.2
EOF
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有