Beaglebone Sudoers File get Corrupted.

Hi,
I did a some change in sudoers file, so i can not be root , i can not use sudo or su
debian@beaglebone: sudo su -
sudo: >>> /etc/sudoers: syntax error near line 23 <<<
sudo: parse error in /etc/sudoers near line 23
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

How can I correct this file ?
Thank You

Do you have the root password? If so you can su and then fix it. If not you should look up how to break in to a Linux system, which is usually a mod to the boot command. Search for single user mode. Probably you’ll need a serial to USB cable for your board. If you messed up the image on the mmc instead you can boot off an SD card and then chroot to the emmc image and reset the root pass.

Next time you edit your sudoers file use the command visudo which will check that the file is valid prior to saving.

Jim

On Tue, 19 Mar 2019 03:56:36 -0700 (PDT),
sayalikutwal07@gmail.com declaimed the
following:

Hi,
I did a some change in sudoers file, so i can not be root , i can not use
sudo or su
debian@beaglebone: sudo su -
sudo: >>> /etc/sudoers: syntax error near line 23 <<<
sudo: parse error in /etc/sudoers near line 23
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

How can I correct this file ?

  If that is in the eMMC, boot with a fresh SD card image.
  If that is in an SD card, remove it and boot from the eMMC image

THEN
  Mount the other device (insert the SD card if booting from eMMC)
somewhere into the file system...
  Copy the good /etc/sudoers file from the booted system to
/whereever/mounted/etc/sudoers...

  Dismount, reboot

  And, as mentioned elsewhere, only use "visudo" to edit the sudoers
file; do not edit it by hand using any other command.

Hi - do you think this process would work for recovering /etc/passwd when, despite typing it three times (change, confirm, into notes), my new debian user password isn’t accepted.

Single user mode on BBB seems non-trivial and I’d rather not start again with my config.

Thanks,
Dan

Yes, same concept. Once you have the system booted, set your password then copy the /etc/passwd file over to the other partition. I forget if the default BB image uses shadow password file so if there’s no password data in the passwd file you might need to copy over the /etc/shadow file too. Make sure to preserve the user and group ownership and permissions too.

J

On Wed, 10 Apr 2019 03:53:49 -0700 (PDT), Dan Sloane
<dan@sloane-squared.com> declaimed the
following:

Hi - do you think this process would work for recovering /etc/passwd when,

  Passwords may not even be /in/ /etc/passwd -- I know Mandrake
(Mandriva/Mageia) implemented a shadow password system 15-20 years ago.
Reason: /etc/password is pretty much globally readable, and even with a
one-way hash for passwords, being able to read the hashed password makes it
simpler to hack the accounts on a machine (generate random passwords using
the account's seed value until the hash matches).

  The shadow file is in protected directory and only readable by the
login/security functions.

Thanks both.

Looks like the shadow file was updated around the correct time last night. Moral of the story: don’t update passwords at close to 1am.

debian@beaglebone:/etc$ ls -l pass* shadow*
-rw-r–r-- 1 root root 1611 Feb 7 23:56 passwd
-rw------- 1 root root 1611 Feb 7 23:56 passwd-
-rw-r----- 1 root shadow 1045 Apr 10 00:49 shadow
-rw------- 1 root root 960 Feb 7 23:56 shadow-

Dan