这个脚本安全吗?

发布于 2024-11-01 05:18:02 字数 838 浏览 1 评论 0原文

我需要执行一些服务器任务。现在我多次听到这是非常不安全的。这是我的解决方案:

将此行添加到 sudoers: www-data ALL=NOPASSWD: /var/private-www/bin/webadmin (无法通过网络访问)

创建了此脚本var/private-www/bin/webadmin

# Script for executing server tasks.
#
# Arguments:
#  - Password       Required for authentication, not all scripts may run this file
#  - Action         Action to execute
# Exit codes:
#  0                Failed
#  1                Success

# First of all check the password
if [ $1 = "secretpassword" ]
then

whoami
exit 1

else

echo "No access"
exit 0

fi

该文件具有以下权限: 0111

仅对一个帐户启用 SSH 访问。所以除了我(和 www-data)之外,没有人可以执行该脚本。 www-data 现在可以通过执行以下操作来访问此文件: exec('/usr/bin/sudo /var/private-www/bin/webadmin Secretpassword', $output, $status);

这足够安全吗?我怎样才能让它更安全?

I need to execute some server tasks. Now I heard many many times this is very insecure. This is my solution:

Added this line to sudoers:
www-data ALL=NOPASSWD: /var/private-www/bin/webadmin (Not accessible through web)

Created this script var/private-www/bin/webadmin:

# Script for executing server tasks.
#
# Arguments:
#  - Password       Required for authentication, not all scripts may run this file
#  - Action         Action to execute
# Exit codes:
#  0                Failed
#  1                Success

# First of all check the password
if [ $1 = "secretpassword" ]
then

whoami
exit 1

else

echo "No access"
exit 0

fi

The file has these rights:
0111

SSH access is only enabled for one account. So nobody can execute the script, except me (and www-data). www-data can now access this file by doing:
exec('/usr/bin/sudo /var/private-www/bin/webadmin secretpassword', $output, $status);

Is this safe enough? How can I make it more secure?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丑疤怪 2024-11-08 05:18:02

我认为如果你的 Apache 服务器被破解,有人可以访问该脚本并执行它,但我可能是错的。

我遇到了您可能想阅读的资源,特别是当涉及到将脚本限制到内部网络时。

http://www.linuxsecurity.com/content/view/133913/171/

我希望这能回答您的问题。

I'm thinking that if your Apache server gets cracked, someone could access that script and execute it, but I might be wrong.

I've came across a resource you might want to read about, especially when it comes to restricting your script to your internal network.

http://www.linuxsecurity.com/content/view/133913/171/

I hope this answers your question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文