小编Din*_*esh的帖子

如何在 sudoers 中使用带有 Cmnd_Alias 的命令参数?

如何在 sudoers 中指定命令参数?作为背景,aws命令实际上是通向一大堆子系统的网关,我想限制用户只能运行aws s3 cp ...any other args...

当我尝试以下 /etc/sudoers

Cmnd_Alias AWSS3_CMD = /usr/local/bin/aws s3 cp, /usr/local/aws/bin/aws s3 cp
gbt1 ALL=(gbt-ops) NOPASSWD: AWSS3_CMD
Run Code Online (Sandbox Code Playgroud)

不幸的是,shell 提示输入密码

$ sudo -u gbt-ops aws s3 cp helloworld s3://my-bucket/hw.1
gbt-ops's password:
Run Code Online (Sandbox Code Playgroud)

如果我删除 Cmnd_Alias 中的命令参数,那么它会按需要流动(没有密码提示),但授权范围太广。那么,限制仅某些类型的命令调用的正确方法是什么

Cmnd_Alias AWSS3_CMD = /usr/local/bin/aws, /usr/local/aws/bin/aws
Run Code Online (Sandbox Code Playgroud)

然后

$ sudo -u gbt-ops aws s3 cp helloworld s3://my-bucket/hw.1
...happy
Run Code Online (Sandbox Code Playgroud)

非常感谢。

sudo

44
推荐指数
2
解决办法
8万
查看次数

如何暂时禁用用户的 cronjobs?

如何暂时禁用一个或多个用户的 cron 作业?特别是,我不想暂停用户的 cron 权限——只是不想解雇他们的任何工作。

我在 SLES 11 SP2 和 SP3 系统上

cron

17
推荐指数
3
解决办法
5万
查看次数

如何使用 tcpdump 捕获和查看数据包内容

我正在尝试将 HTTP 流量传输到文件中的端口 8007,然后再查看它们。

# tcpdump -i eth0 -s0 -n -w /tmp/capture port 8007 &
# tcpdump -r /tmp/capture -A | grep '10.2.1.50'
Run Code Online (Sandbox Code Playgroud)

我希望看到 ASCII 格式的数据包数据,但这并没有发生。我得到的是这样的:

23:03:16.819935 IP 10.2.1.50.8007 > 10.2.1.120.57469: . ack 1369 win 272 <nop,nop,timestamp 188139705 215355175>
23:03:16.819943 IP 10.2.1.120.57469 > 10.2.1.50.8007: P 1369:1592(223) ack 1 win 12 <nop,nop,timestamp 215355175 188139703>
23:03:16.819947 IP 10.2.1.50.8007 > 10.2.1.120.57469: . ack 1592 win 272 <nop,nop,timestamp 188139705 215355175>
23:03:17.029587 IP 10.2.1.50.8007 > 10.2.1.120.57469: P 1:780(779) ack 1592 win 272 <nop,nop,timestamp 188139758 215355175> …
Run Code Online (Sandbox Code Playgroud)

tcpdump

13
推荐指数
3
解决办法
5万
查看次数

在 AWS AMI 上恢复 /bin/hostname

我不小心删除了/bin/hostname。我暂时在那里放入了一个返回已知名称的 shell 脚本。但是如何恢复丢失的二进制文件?

它是一个 AWS AMI。

Linux ip-10-2-0-162 3.4.62-53.42.amzn1.x86_64 #1 SMP Fri Sep 20 07:23:24 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)

software-installation package-management aws

1
推荐指数
1
解决办法
244
查看次数