Security – How to require a sudo password on Google Compute Engine instances

google-cloud-platformgoogle-compute-engineSecurity

The default configuration of Google Compute Engine instances allows administrators to run all commands via sudo without specifying a password. This seems like a security weakness, because the theft of one SSH key belonging to an admin could allow unlimited access to every instance, and all data could be compromised. Requiring a password for sudo would provide a second level of security by preventing an attacker from obtaining root privileges. An attacker would also have to crack an admin's sudo password to access sensitive data or perform destructive acts.

It seems like it should be possible to configure sudo on each instance to require a password, but then each admin would then have to manually set a password on each instance. This approach would not scale well across many instances. Does Google Cloud Platform support any form of password management? If not, how can I require password for sudo in a way that scales well with many instances and multiple admins?

Best Answer

You can limit the sudo access project wise through User Accounts feature which is currently in beta release. More information is mentioned here:

Root access

All Linux user accounts in your project are granted root access to your instances. By default, new Linux user accounts are added to the following user groups upon account creation:

gce-sudoers - Gives root access gce-users - General users group The gce-sudoers group is automatically maintained by the Cloud User Accounts service and contains every Linux user account in your project. If you wanted to restrict root access to certain accounts, remove the default policy at:

/etc/sudoers.d/gcua

Next, create your own group and add a configuration similar to the gcua file in the sudoers.d folder.