简体   繁体   English

Azure Ubuntu VM-Waagent配置

[英]Azure Ubuntu VM - Waagent configuration

I have on my Ubuntu 16.04 VM in /etc/sudoers.d/waagent the configuration that is unwanted. 我在/etc/sudoers.d/waagent的Ubuntu 16.04 VM上有不需要的配置。 Even if I log as root, root has only read permission. 即使我以root用户身份登录,root也仅具有读取权限。

How should I safely edit configuration for Azure waagent ? 我应该如何安全地编辑Azure waagent的配置?

I wanna change someuser ALL=(ALL) NOPASSWD:ALL to someuser ALL=(ALL) ALL 我想将someuser ALL=(ALL) NOPASSWD:ALL更改为someuser ALL=(ALL) ALL

Can I simply add write permission for root and edit the file or need I do it in different way via Azure commands? 我可以简单地为root添加写权限并编辑文件,还是需要通过Azure命令以其他方式进行操作?

I would like to prevent the case when sudo configuration is damaged due fact I have no physical access to VM and cannot fix it. 我想防止sudo配置损坏的情况,因为我没有对VM的物理访问权并且无法修复它。

For your issue, I think there is no more safe way to edit the /etc/sudoers.d/waagent(in my side, the file name is /etc/sudoers.d/90-cloud-init-users). 对于您的问题,我认为没有更多安全的方法可以编辑/etc/sudoers.d/waagent(在我这一边,文件名为/etc/sudoers.d/90-cloud-init-users)。 The file just can be edited with the root permission. 只需使用root权限即可编辑该文件。 If you use the root to edit then everything works in the same way. 如果使用根进行编辑,则所有内容均以相同的方式工作。

So I suggest you can just use the root user, add the write permission and edit the file as you want. 因此,我建议您可以只使用root用户,添加写许可权并根据需要编辑文件。 But do not forget to change the permission back, in other words, remove the write permission when everything is OK. 但是不要忘了将权限改回来,换句话说,当一切正常时,删除写权限。

Short answer: 简短答案:

Use visudo -f /etc/sudoers.d/waagent 使用visudo -f /etc/sudoers.d/waagent

Long answer: 长答案:

When editing sudoers files, always use visudo . 编辑sudoers文件时,请始终使用visudo It is a vi editor, but includes built-in checks to prevent you from corrupting the file and will allow you to save the file even though there's no write permissions on the file (assuming you run it as root). 它是一个vi编辑器,但包含内置检查功能,以防止损坏文件,即使对文件没有写权限(假设您以root身份运行),也可以保存文件。 Changing the permissions on the file to allow write access and using a normal text editor is a bad idea. 更改文件的权限以允许写访问并使用普通的文本编辑器是一个坏主意。 Too easy to forget to change it back and one misplaced symbol or misspelled word can corrupt the file. 太容易忘记忘记将其改回,一个错误放置的符号或拼错的单词可能会损坏文件。 That's why there is no write permission by default - to act as a check to prevent unwanted modifications that could potentially render your system unusable. 这就是默认情况下没有写权限的原因-用作检查以防止可能导致您的系统无法使用的不必要的修改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM