我正在寻找默认的Amazon AMI linux映像为默认的ec2-user帐户设置权限的位置。
用这个帐户login后,我可以成功地使用sudo。 通过sudoers文件检查,通过运行visudo打开(没有其他选项),我看到几个默认的设置和root权限ALL ALL
那么… ec2用户的权限在哪里分配?
我还没有尝试添加新的权限,但最终我想要辞去ec2用户的系统pipe理任务,并使用非完整的root用户来pipe理应用程序(停止和启动mysql,httpd,编辑apache的虚拟主机文件,并上传/编辑web根目录下的web内容)
它在/etc/sudoers.d/cloud-init 。 我也可以尽快从生产系统中删除它。
它是凭借这一行列入的
#includedir /etc/sudoers.d
在/etc/sudoers文件中。 请注意,正如它所说的那样,前导#不被视为注释符号。 在我的一些服务器上,它也在 /etc/sudoers.d/90-cloud-init-users ; 使用ec2用户的用户可能是最安全的。
实际上它是来自/etc/sudoers.d/的一个文件
From the master sudoers file, the very last part: ## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment) #includedir /etc/sudoers.d
具体来说,在这里读#的小字并不意味着评论
接着:
[root@webmaster ec2-user]# cd /etc/sudoers.d/ [root@webmaster sudoers.d]# ls -l total 4 -r--r----- 1 root root 88 May 5 09:16 cloud-init [root@webmaster sudoers.d]# grep ec2-user * ec2-user ALL = NOPASSWD: ALL # User rules for ec2-user ec2-user ALL=(ALL) NOPASSWD:ALL
瞧。