0

I have a projected hosted on a virtual machine instance (with ubuntu onboard) which runs in GCP-Compute Engine.

When I want to elevate my priveleges typing "sudo -i", ubuntu asks me a passoword, what kind of password does google cloud want?), I tried my gcp account's password and it does not work hope you can help with some ideas on this

example picture

Best regards,

8
  • sudo usually needs your accounts' password. Why do you use sudo -i though? Commented Oct 25, 2019 at 13:35
  • sudo -i to use root priveleges Commented Oct 25, 2019 at 13:36
  • I edited the sudoers file, trying to add a new user, after this I lost the ability to use "sudo", also observed that the string which were before printed like (Connected, host fingerprint: ssh-rs .....) is missing now Commented Oct 25, 2019 at 13:40
  • sudo means su do, which in most cases means: superuser/root do. You - normally - don't need the -i switch, you use it in conjunction with your needed command, e. g.: sudo apt-get update, or whatever. How did you add your user to sudoers? Commented Oct 25, 2019 at 13:43
  • I typed "sudo visudo", and added after admin line, if I rembmer correctly I've added something like "newName ALL=(ALL:ALL)ALL". Commented Oct 25, 2019 at 13:50

1 Answer 1

0

The Short answer

  • You killed your /etc/sudoers
  • Verify the Integrity´with visudo -c
    • if everything is ok it will give you an output like

      root@f00bar:/# visudo -c /etc/sudoers: parsed OK /etc/sudoers.d/README: parsed OK 

The Long Answer:

Default Sudo File

(In case you want to overwrite your one)

## Default Debian `/etc/sudoers` # # This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # Defaults env_reset Defaults mail_badpass Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL:ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d 

Use "visudo"

Manpage visudo

visudo edits the sudoers file in a safe fashion, analogous to vipw(8).

visudo locks the sudoers file against multiple simultaneous edits, provides basic sanity checks, and checks for parse errors.

If the sudoers file is currently being edited you will receive a message to try again later.

visudo parses the sudoers file after editing and will not save the changes if there is a syntax error. Upon finding an error, visudo will print a message stating the line number(s) where the error occurred and the user will receive the “What now?” prompt. At this point the user may enter ‘e’ to re-edit the sudoers file, ‘x’ to exit without saving the changes, or ‘Q’ to quit and save changes.

The ‘Q’ option should be used with extreme caution because if visudo believes there to be a parse error, so will sudo and no one will be able to run sudo again until the error is fixed.

If ‘e’ is typed to edit the sudoers file after a parse error has been detected, the cursor will be placed on the line where the error occurred (if the editor supports this feature).

Howto get Password-Less Sudo User?

  • YOUR_USERNAME_HERE ALL=(ALL) NOPASSWD: ALL

Howto get Password-Less Sudo Group?

  • %YOUR_GROUPNAME_HERE ALL=(ALL) NOPASSWD: ALL

    • The Difference is, users are without and User-Groups with a Percent written in front of them.

Conclusion

Dont edit the sudo file on your own, if you are unfamilar with the Syntax.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.