简体   繁体   English

sudo 请求密码(但以前从未有过)

[英]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.我将谷歌 sdk shell 与 PuTTy 结合使用来访问运行 debian 的计算引擎实例。我有一个 SSH 密钥设置并且始终能够访问服务器并根据需要运行 sudo 命令(多年)但在空间几个小时后,每次尝试 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.我仍然可以访问并可以使用 CD、nano 文件等,但如果我尝试 sudo nano,它就不是 go。我从来没有设置过 sudo 密码 (AFAIK),因为我一直使用 ssh 密钥——但如果有办法,我会做它。

I rechecked I have editor and Compute Instance Admin (v1) roles in IAM and my key is installed我重新检查了我在 IAM 中拥有编辑器和计算实例管理员 (v1) 角色并且我的密钥已安装

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谷歌云 SDK Shell 命令

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 Putty 然后打开并响应以下内容

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. 1)检查您的 SSH 密钥是否有过期日期,这就是 sudo 要求输入密码的原因。 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. 2)Google Cloud Shell 在幕后为您管理实例元数据,并允许以这种方式添加到项目中的所有用户使用无密码 sudo。

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. 3)设置无密码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.您可以(使用 visudo)编辑 /etc/sudoers 或在 /etc/sudoers.d 下创建一个新文件并添加如下一行: user123 ALL = (ALL) NOPASSWD: ALL您可以看到 google 是按组成员身份执行的在 google-sudoers 组中。

4)Please check the official doc for Connecting to a serial console with a login prompt . 4)请查看官方文档以使用登录提示连接到串行控制台

5)Try this similar SO1 , SO2 for more information. 5)试试这个类似的SO1SO2了解更多信息。

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

相关问题 SSH:如何知道gcloud自动创建的sudo用户的密码? - SSH: How to know the password of sudo users created automatically by gcloud? 编辑之前已成功上传图像的记录时,我如何不必在编辑时重新上传? - When editing a record that has a previously successfully uploaded image, how do I not have to re-upload on edit? Firebase 使用email登录后google登录报错:密码无效或用户没有密码 - Firebase Sign-in with email after google sign-in has error : The password is invalid or the user does not have a password 可以通过 AWS 中的 secretmanagerid 检索或刷新密码,密码已按策略每五分钟轮换一次 - It´s possible retrive or refresh a password by secretmanagerid in AWS, the password has been rotated by a policy every five minutes 在 React 中使用 Firebase 9、Redux 工具包和 Typescript 让人头疼。 “dispatch”以某种方式具有“never”类型? - Getting headaches using Firebase 9, Redux Toolkit and Typescript in React. 'dispatch' somehow has type 'never'? 使用 sudo 找不到命令“sam” - command 'sam' not found using sudo 未找到 sudo npm install 命令 - sudo npm install command not found GCP 计算引擎 API 继续请求 - GCP Compute Engine API keep requesting 我的 AWS CLI 不适用于 sudo - My AWS CLI didn't work with sudo Java AWS 上的 sudo 用户的主文件夹不同 - Java home folder is different for sudo user on AWS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM