-1

I have SSH key access to my homelab ubuntu machine from my main computer and I didnt have to use the password for months. Now I am trying to access the machine from my laptop but I have forgotten the password. Is there a way to reset the password from my main computer while SSH'ed into it? I can not sudo due to this.

Or the only way is the physical way by mounting during boot?

  • Do you have access to Docker or something like that without having to use sudo? – muru Dec 24 '23 at 11:29
  • Yes, i am running docker in that machine – Gary Tanz Dec 24 '23 at 15:18
  • Then you can do something like docker run -it -v /etc:/etc ubuntu:$(lsb_release -sd) to get a root shell in the container with access to your system's /etc, and then change the password to whatever you want – muru Dec 24 '23 at 15:56
  • I get error: Unable to find image 'ubuntu:Ubuntu' locally – Gary Tanz Dec 24 '23 at 17:35
  • Update, i manually put 22.04 on the tag and i got root access. My next question would be, when I try passwd userFoo , i get passwd: Module is unknown passwd: password unchanged – Gary Tanz Dec 24 '23 at 17:45
  • Last update, passwd worked after installing libpam-pwquality Thanks for your help – Gary Tanz Dec 24 '23 at 17:47
  • Oh yeah, it should have been -sr to get the version number as the tag using lsb_release and not -sd, my bad. Good to know you have fixed it. Since you needed to do additional things on top of my suggestion, consider posting an answer detailing exactly what you did. – muru Dec 25 '23 at 00:51

1 Answers1

-1

I was able to get around this with docker, by using @muru's recommendation.

Gain root access: docker run -it -v /etc:/etc ubuntu:$(lsb_release -sr)

Prerequisite package for passwd: apt-get install -y libpam-pwquality

Use passwd on the profile you are trying to change passwords: passwd userFoo