我已经阅读了与该问题相关的所有帖子。但如果你能看到我的并提出建议。
我正在尝试使用无密码SSH并在远程服务器上运行脚本。但Sudo访问要求密码。请建议。它适用于本地路径。但是任何命令或脚本都要求root访问失败。
以下是脚本:
#!/bin/sh
#set -x
# This Script will search for mib files on Current Server and other Server
# to load mib on current Server.
if [ -f /home/shuksand/Script/MibSearch.conf ]
then
. /home/shuksand/Script/MibSearch.conf
else
echo "Failed to find config file. Hence Existing!!!!"
fi
# Check alll MIBS on Server
while read line
do
ServerName=$line
echo $line
scp /home/shuksand/Input/Mib.txt $ServerName:
cat /home/shuksand/Input/Mib.txt | while read DATA
do
echo $DATA
ssh -t -t shuksand@${ServerName} 'sudo su - root /bin/sh /home/shuksand/Mib.sh $DATA'
done
done < /home/shuksand/Input/ServerList.txt
提前致谢!!