Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud VM when sudoing asks for password

I've been working with a Google Cloud debian VM and had no problem at all doing super user tasks using sudo (sudo was not asking for password).

Today I connected via SSH as usual and when I try to sudo something it started asking for password:

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for -----:

According to the documentation it should not ask for password as is already SSL Key authenticated connection.

like image 398
Esteban Panelli Avatar asked Dec 18 '25 21:12

Esteban Panelli


2 Answers

Today I had the same problem with CentOS 8.x VM. After some testing I found a more simple solution. The group "google-sudoers" is allowed to sudo in /etc/sudoers.d/google_sudoers file, so, to fix the problem and make it permanent add your user to "google-sudoers" group with the next steps:

  1. SSH to your VM from GCP's web console
  2. Run sudo usermod -a -G google-sudoers USER to add your USER to google-sudoers group
  3. Close your current SSH session and open a new one
  4. Test that everything works ok

You should be able to run sudo commands or gain root again.

like image 89
Angel Leon Avatar answered Dec 20 '25 16:12

Angel Leon


To avoid this, one solution is open the ssh terminal on the web browser from GCP console. You can give a try on this. This is because of SSH key related configuration on Google Clound Engine

like image 40
Nizamudheen At Avatar answered Dec 20 '25 16:12

Nizamudheen At



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!