该脚本应该将密钥从ossec服务器分发给它的客户端
cat /usr/local/bin/dist-ossec-keys.sh
#!/bin/sh
#
for host in chef-production2-doctor-simulator01
do
echo "host is $host"
key=`mktemp`
grep $host /var/ossec/etc/client.keys > $key
echo "key is $key"
scp -i /var/ossec/.ssh/id_rsa -B -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $key ossecd@$host:/var/ossec/etc/client.keys >/dev/null 2>/dev/null
rm $key
ech "done"
done
我逐行运行脚本,它的输出是
host is chef-production2-doctor-simulator01
key is /tmp/tmp.fAZqvNkJ9f
bash脚本是从this模板
创建的cat /var/ossec/etc/client.keys
001 #*#*#*#*#*#*#*#*#*#*#197.221.226 7196c76c568258e2ad836f8e1aa37e0758dee969f560ceb59be76879c3f3412d
002 test-agent 10.128.0.9 e2c9b117f26a202598007dcb4ec64e01f18000f9d820f6b3508a95e5313e6537
该怎么办? 为什么不起作用?
答案 0 :(得分:0)
错误发生在scp -i /var/ossec/...
行
我糟糕的Linux知识未能注意到
>/dev/null 2>/dev/null
删除显示真实错误(Permission denied (publickey)
)