Sudo password for user как узнать пароль
Перейти к содержимому

Sudo password for user как узнать пароль

  • автор:

How to get password for sudo

I’m trying to use the command sudo -i -u postgres for PostgreSQL, and the Google Compute Engine VM is asking me for my password for my account (not root).

As I never issued a password, and I always login to my server via SSH key, I’m not sure what the password is, how I can reset it, or where it can be found.

Please tell me where I can get my password?

Misha Brukman's user avatar

3 Answers 3

Answer recommended by Google Cloud

To become another non-root user on a GCE VM, first become root via password-less sudo (since that’s how sudo is configured on GCE VM images):

and then switch to the user you want to become or run a command as another use, e.g., in your case, that’s:

Misha Brukman's user avatar

The instance creator and any users that were added using the metadata sshKeys value are automatically administrators to the account, with the ability to run sudo without requiring a password.

So you don’t need that non-existent password — you need to be «added using the metadata sshKeys value»! The canonic way to do that, and I quote from that same page:

or you can use the Google Developers Console for similar purposes, see https://cloud.google.com/compute/docs/console#sshkeys if you’d prefer that.

Summary

While creating the VM, specify the ssh user in the «Enter the entire key data» box.

Details

  1. generate the ssh key pair and identify the public key:
    • if ssh-keygen, a file ending with «.pub»
    • if PuTTYgen, the text in box «Public key for pasting . «

Notice the fields, all one one line, separated by spaces: «protocol key-blob username». For username, you may find your Windows user name or a string like «rsa-key-20191106». You will replace that string with your choice of Linux user name.

Paste the public key info into the «Enter the entire key data» box.

Change the 3rd field to the actual user that you want to create on the VM. If, for example, «gcpuser», then:

create your VM. (Debian, for example)

Connect to the VM

  • directly from ssh or PuTTY (not browser window)
  • use the private key
  • specify the user

Notice that your public key is present:

Notice that you are in group google-sudoers

sudo to root with no password

Notice the sudoers file:

Conclusion

Specifying the username in «Enter the entire key data» has these results:

  1. creating the user in the virtual machine.
  2. uploading the key to

unixforum.org

[РЕШЕНО] забыл пароль от su/sudo (помогите как сбросить/восстановить?)

Модератор: Bizdelnick

[РЕШЕНО] забыл пароль от su/sudo

забыл пароль от su/sudo помогите как сбросить/восстановить?

чуть не забыл дистр kubuntu 9

Re: [РЕШЕНО] забыл пароль от su/sudo

Re: [РЕШЕНО] забыл пароль от su/sudo

$ su
Пароль:
su: Ошибка аутентификации
пароль точно верный что делать подскажите?

Re: [РЕШЕНО] забыл пароль от su/sudo

Сообщение Nymin » 15.05.2009 14:24

Re: [РЕШЕНО] забыл пароль от su/sudo

$ su
Пароль:
su: Ошибка аутентификации
пароль точно верный что делать подскажите?

Re: [РЕШЕНО] забыл пароль от su/sudo

$ su
Пароль:
su: Ошибка аутентификации
пароль точно верный что делать подскажите?

What is my sudo password?

When installing things I am sometimes asked for my sudo password. I don’t remember ever having one or setting one. But I do know my su password which has always worked fine for me. It is not the same as my sudo as it doesn’t work when I try it.

How do I find out what my sudo password is?

Gilles 'SO- stop being evil''s user avatar

3 Answers 3

It is usually your personal login password. For example:

This can be altered by policy files such as /etc/sudoers. See for example Set sudo password differently from login one

msw's user avatar

If you have root password.

Look in file /etc/sudoers . You will find a line like %sudo ALL=(ALL:ALL) ALL , make a note of the word after the % . Now add your self to this group. Logout. Login. Now sudo should work for you.

If you don’t have root password, then use a live distro to do what is described above.

How To Reset Sudo Password In Ubuntu 22.04 / 20.04 LTS

This brief guide explains how to reset sudo password in Ubuntu 22.04 and 20.04 LTS desktop and server editions from rescue mode.

Introduction

When installing Ubuntu, a new user will be created with sudo privileges to perform all sorts of administrative tasks.

If your Ubuntu system have multiple sudo users, you can easily reset the forgotten password of a sudo user or administrative user from another sudo user’s account.

What If you have only one sudo user and you lost the password? No problem! It is very easy to recover forgotten sudo user password in Ubuntu from the «rescue» or «single user» mode.

This guide has been officially tested on Ubuntu 22.04 and 20.04 LTS editions, however the steps given below are same for other Ubuntu versions and derivatives.

Reset Sudo Password In Ubuntu 22.04 / 20.04 LTS

First, boot your Ubuntu system into rescue mode to reset a sudo user’s password as described in the link below.

After you entered into the rescue mode, mount the root ( / ) file system in read/write mode by running the following command:

Now, reset the sudo user’s password using » passwd « command:

Here, «ostechnix» is the sudo user. Replace it with your own user name.

Enter the password twice:

Reset Sudo Password In Ubuntu 22.04 / 20.04 LTS System

Reset Sudo Password In Ubuntu 22.04 / 20.04 LTS

That’s it. We have reset the sudo user password. If you have followed the Method 1 to enter into rescue mode as described in the above link, press “ Ctrl+d ” to boot into normal mode. Alternatively, you can type any one of the following commands to boot into normal mode.

If you want to reboot the system instead of booting into normal mode, enter:

If you have followed the Method 2 to enter into rescue mode as described in the above link, type:

You will go back to the recovery menu. Choose «Resume normal boot» and hit ENTER key.

Boot Into Normal Mode In Ubuntu

Boot Into Normal Mode In Ubuntu

Again, choose OK and press ENTER to continue booting into normal mode:

Exit Recovery Mode And Boot Into Normal Mode

Exit Recovery Mode And Boot Into Normal Mode

You can now use the new sudo password when running administrative commands.

What If I Forgot Both Username And Password?

If you forget the username, you can easily list the available users in your Linux system from the rescue mode using command:

Sample output from my Ubuntu 22.04 system:

Well, you now have the user name. Just follow the aforementioned steps to reset the user’s password.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *