Reset your lost password using Docker and SSH

We’ve all been there. You turn on a machine in your home-lab, your Raspberry Pi, or an old PC and you’ve forgotten your password. At this point you start Googling, and that might be what brought you here.


I bought this C30 bargain Xeon workstation on eBay in 2019


  • Docker already installed on the machine
  • SSH access with your public key in the authorized_keys file

Find the host’s IP

First, shell into the machine. You will need the remote IP address of the host, and if you are not sure of it, you can use nmap to scan your local home network to find out what IPs are available to try.

nmap -sP

Let’s reset that password

You won’t need your password for this, but you must have previously copied your SSH key to the remote machine.

ssh alex@remote-host
docker run -v /etc/:/etc/ -ti ubuntu
docker images
/ # passwd alex
Changing password for alex
New password:
Retype password:
passwd: password for alex changed by root

In conclusion

That was relatively painless. There was no need to boot into recovery mode, or to use a USB pen-drive, or to thrash around on the Internet for posts titled “resetting my password on Linux”.


Further resources:

ssh-keygen can be used to generate an SSH key, and ssh-copy-id can be used to copy it to a remote machine for password-less login.

You may also like

CNCF Ambassador. OpenFaaS & Inlets founder —

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store