Created
February 8, 2015 14:07
-
-
Save jriguera/f97925ca7534a75eedfa to your computer and use it in GitHub Desktop.
Raspberry PI password recovery for arch linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# | |
# Raspberry PI password recovery for arch | |
# The SD should be mounted on $DEV (usually sdb2) | |
USER=root | |
PASSWORD=hola | |
DEV=sdb2 | |
# Creating SHA512 password for arch | |
PASS=$(echo "$USER:$PASSWORD" | chpasswd -c SHA512 -S | cut -d: -f2) | |
# Looking for the mountpoint | |
BASE=$(mount | awk "/\/dev\/$DEV/ { print \$3 }") | |
# Creating backup | |
sudo cp -a $BASE/etc/shadow $BASE/etc/shadow.old | |
# Updating file with the new password | |
sudo sed -i "s|^\(${USER}\):\([^:]*\):\(.*\)\$|\1:${PASS}:\3|g" $BASE/etc/shadow | |
sync |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment