Created
February 3, 2021 00:43
-
-
Save landonc/6ad8fdb2f5144feb6e929b64df45bfbe to your computer and use it in GitHub Desktop.
s6 root with ssh in recovery
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
# mash the ssssssssssssssssssssssssss on boot to interrupt over uart | |
# get into single user mode | |
setenv boot_fs a | |
setenv setargs_mmc ${setargs_mmc} init=/bin/sh | |
boot | |
# As soon as the system boots (you have 5 seconds): | |
echo 'V' > /dev/watchdog | |
# take ownership of the /root directory and set the permissions correctly | |
chown root:root /root; chmod 700 /root; mkdir /root/.ssh; chmod 700 /root/.ssh | |
# use vi to add ssh pub key to /root/.ssh/authorized_keys | |
# set the permissions of authorized_keys correctly | |
chmod 600 /root/.ssh/authorized_keys | |
In Linux | |
-------- | |
iptables -F | |
(you can run the next commands over SSH) | |
sed -i -e '/ iptables -I INPUT -j DROP -p tcp --dport 22/s/^/#/g' /opt/rockrobo/watchdog/rrwatchdoge.conf | |
sed -i -E 's/dport 22/dport 29/g' /opt/rockrobo/watchdog/WatchDoge | |
sed -i -E 's/dport 22/dport 29/g' /opt/rockrobo/rrlog/rrlogd | |
mkdir /mnt/recovery | |
mount /dev/mmcblk0p7 /mnt/recovery | |
sed -i -e '/ iptables -I INPUT -j DROP -p tcp --dport 22/s/^/#/g' /mnt/recovery/opt/rockrobo/watchdog/rrwatchdoge.conf | |
sed -i -E 's/dport 22/dport 29/g' /mnt/recovery/opt/rockrobo/watchdog/WatchDoge | |
sed -i -E 's/dport 22/dport 29/g' /mnt/recovery/opt/rockrobo/rrlog/rrlogd | |
# copy the .ssh folder and authorized_keys to the recovery partition and set all the permissions correctly for after reset | |
cp -R /root/.ssh /mnt/recovery/root/ | |
chown -R root:root /mnt/recovery/root; chmod 700 /mnt/recovery/root; chmod 600 /mnt/recovery/root/.ssh/authorized_keys | |
umount /mnt/recovery |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment