mhr320
Posts: 6
Joined: Mon Feb 17, 2020 10:48 pm

PubkeyAuthorization no, PasswordAuthorization no I changed these, now I am stuck

Mon Feb 17, 2020 11:01 pm

I was thinking of other things when I changed my PubkeyAuthorization from yes to no. Then before I used my brain, I closed my terminal and was magically locked out of my Rpi. I'm using the Rpi as a headless server. I need to recover files from the system. I attempted to change the /etc/ssh/sshd_config file by popping the SD card into another linux/mac but the files are all read-only. I went through several forums and attempted to start in "safe mode" or "maintenance mode" by editing the cmdline.txt, but again, "read-only". Most importantly here, this is of my own doing. The Rpi boots up beautifully and is still serving the websites I have on it just fine. But this will not last. I connected a monitor to the Rpi with a keyboard, but as expected, it will not allow me to login in. It tells me my login is incorrect. I attempted to hit the shift key, but I am not using NOOBS (i don't think). I did not change PasswordAuthorization to no, I simply forgot to uncomment the line. It is marked yes.

Any thoughts on how to get access to the system? I have also attempted to scp/sftp a new file but it wants a password that it is properly not configured to receive. Bless you all!

User avatar
rpdom
Posts: 16774
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: PubkeyAuthorization no, PasswordAuthorization no I changed these, now I am stuck

Tue Feb 18, 2020 8:26 am

Something is not right there.

You should be able to access your files on the SD card with another Linux system. I do it all the time.
Are you using root/sudo to access the card?
It may haven mounted read-only if errors were detected in the filesystem. Possibly unmounting it and running fsck on it will fix that.

You should be able to log in locally with a keyboard and monitor using the standard user and password. The "PasswordAuthentication" option in sshd_config does not affect local logins.
Unreadable squiggle

mhr320
Posts: 6
Joined: Mon Feb 17, 2020 10:48 pm

Re: PubkeyAuthorization no, PasswordAuthorization no I changed these, now I am stuck

Tue Feb 18, 2020 10:13 am

I thought the same. I thought i’d be able to log in at the “box”, make the necessary changes, and move on.
I attempted to view the files as user and as root. It was acting weird with auto mounting but i was able to see boot and rootfs, now on linux, both will not auto mount and my attempt on mac allowed me to see boot only, rootfs did not appear. It still serves the websites and it still boots. Still doesn’t allow logins.
I did attempt ntfsfix yesterday without any luck. I will try fsck next.

GlowInTheDark
Posts: 463
Joined: Sat Nov 09, 2019 12:14 pm

Re: PubkeyAuthorization no, PasswordAuthorization no I changed these, now I am stuck

Tue Feb 18, 2020 10:19 am

Mac will not be able to access rootfs (ext4) without untrusted 3rd party drivers.

Not sure what you mean by "safe mode" or "maintenance mode" - those sound like Windows terms.

Did you try the "init=" trick? If so, be aware that it is a "known feature" that the rootfs comes up read-only. To fix that, do (something like - this is from memory):

Code: Select all

mount -o remount,rw /
After that, you should be able to edit things in the rootfs.
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

mhr320
Posts: 6
Joined: Mon Feb 17, 2020 10:48 pm

Re: PubkeyAuthorization no, PasswordAuthorization no I changed these, now I am stuck

Tue Feb 18, 2020 11:51 am

So I ran across safe mode and maintenance mode on this forum regarding NOOBS installation. I have successfully tried the init trick and i’m sitting at the command prompt
I attempted

Code: Select all

mount -o remount,rw /
received-
mount: can’t find PARTUUID=23cfa8d7-02

mhr320
Posts: 6
Joined: Mon Feb 17, 2020 10:48 pm

Re: PubkeyAuthorization no, PasswordAuthorization no I changed these, now I am stuck

Tue Feb 18, 2020 12:27 pm

Update!

It is solved. I re-attempted

Code: Select all

mount -o remount, rw /
and it worked. I was able to change the sshd_config file and for good measure, I changed the password for the user. I also reset all keys and cat > authorized keys the id_rsa.pub. I was able to then edit the cmdline.txt file and remove the init=/bin/bash, reboot and login. Thank you all for your assistance. Lessons learned: backup, backup, backup. This was my first post on a forum that ended with great success. I have 5 Rpi's deployed in my house and I love them. To address one question from GlowInTheDark, What was the "Safemode" I was referring to, I appended S to the end of cmdline.txt and it offered me "maintenance" mode but required a login, which did not work. I then appended init=/bin/bash which did work.

GlowInTheDark
Posts: 463
Joined: Sat Nov 09, 2019 12:14 pm

Re: PubkeyAuthorization no, PasswordAuthorization no I changed these, now I am stuck

Tue Feb 18, 2020 12:41 pm

It is solved. I re-attempted

mount -o remount, rw /
Presumably, without the space after the comma.
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

mhr320
Posts: 6
Joined: Mon Feb 17, 2020 10:48 pm

Re: PubkeyAuthorization no, PasswordAuthorization no I changed these, now I am stuck

Tue Feb 18, 2020 1:23 pm

no, it required the space after the comma, first way failed

GlowInTheDark
Posts: 463
Joined: Sat Nov 09, 2019 12:14 pm

Re: PubkeyAuthorization no, PasswordAuthorization no I changed these, now I am stuck

Tue Feb 18, 2020 2:30 pm

mhr320 wrote:
Tue Feb 18, 2020 1:23 pm
no, it required the space after the comma, first way failed
That's not right.
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

mhr320
Posts: 6
Joined: Mon Feb 17, 2020 10:48 pm

Re: PubkeyAuthorization no, PasswordAuthorization no I changed these, now I am stuck

Tue Feb 18, 2020 2:48 pm

Well, I do not know what to say. I wish I could show you my history from bash, right or wrong, syntactically, I tried the suggestion, based on the poster saying it was from memory, and when it did not work, i tried the iteration with the space and it worked. I will agree every time i’ve seen it posted, it is without the space. But with the space is what worked for me. I really appreciate you helping me. Took a lot of stress off my shoulders.

User avatar
jojopi
Posts: 3193
Joined: Tue Oct 11, 2011 8:38 pm

Re: PubkeyAuthorization no, PasswordAuthorization no I changed these, now I am stuck

Tue Feb 18, 2020 4:46 pm

The mount command with the space will work. It is asking to mount the (nonsensical) device "rw" on directory "/", but because we also specified the "remount" option, the given device is ignored and the existing device is reused. The "rw" option is actually the kernel default, so omitting it does not matter.

The mount command without the space fails in recent images. /etc/fstab specifies the devices by partition UUID, and even though the device will ultimately be ignored for this command, mount tries to determine the device name from the UUID first. This fails when we have booted in single-process mode, presumably because of the lack of /proc, /sys, udevd, systemd, or something like that.

We should probably recommend the command as:

Code: Select all

mount -o remount,rw root /

GlowInTheDark
Posts: 463
Joined: Sat Nov 09, 2019 12:14 pm

Re: PubkeyAuthorization no, PasswordAuthorization no I changed these, now I am stuck

Tue Feb 18, 2020 4:57 pm

Wow - that is bizarre.

The usual comment here would be something like "Thanks for the explanation", but that is just too weird for words.
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

Return to “Raspberry Pi OS”