简体   繁体   中英

sudo requesting password (but never has previously)

I'm using the google sdk shell in combination with puTTy to access a compute engine instance running debian. I have an SSH key setup and have always been able to access the server and run sudo commands as needed (for years) but in the space of a couple of hours I started getting the below message everytime I tried to sudo. I still have access and can CD, nano files etc. but if I try sudo nano it's a no go. I've never setup a sudo password (AFAIK) as I always used an ssh key - but if there's a way I will do it.

I rechecked I have editor and Compute Instance Admin (v1) roles in IAM and my key is installed

Based on other answers I tried these but got the same password request

sudo passwrd

sudo visudo

echo 'password' | sudo -S command

Can anyone help shed some light on what is going on and how to fix it?

Thanks Brad

Response


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 brad:

More Details

Google Cloud SDK Shell command

gcloud compute --project "omega-buckeye-123456" ssh --zone "asia-northeast1-c" "branding-net-2"

results in

Existing host keys found in C:\Users\xxx\.ssh\google_compute_known_hosts 

Putty then opens and responds with the following

Using username "brad".
Authenticating with public key "DESKTOP-DGNOG32\brad@DESKTOP-DGNOG32" from agent
Linux branding-net-2 4.19.0-22-cloud-amd64 #1 SMP Debian 4.19.260-1 (2022-09-29) x86_64


The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Nov 28 06:58:10 2022 from xxx.xxx.xxx.xxx
brad@branding-net-2:~$ 

Check Below Possible Solutions:

1)Check your SSH keys had an expiry date and that was why sudo was asking for a password. Just change the expiry date and everything works again.

2)Google Cloud Shell is managing instance metadata for you behind the scenes, and allows passwordless sudo for all users added to the project this way.

Use google to set up your user Choose an access method & Set up OS Login . Add the

User account you want through the project console. This will propagate that user to all hosts in your project.

3)Set up passwordless sudo. You can (using visudo) edit /etc/sudoers or create a new file under /etc/sudoers.d and add a line like this: user123 ALL = (ALL) NOPASSWD: ALL you can see that google is doing it by group membership in the google-sudoers group.

4)Please check the official doc for Connecting to a serial console with a login prompt .

5)Try this similar SO1 , SO2 for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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