I have run into an issue where I restored my MacBook and lost the SSH private key to my Raspberry Pi, so I can't ssh back into the device. I would like to restore SSH functionality, but when I start my Raspberry Pi and go through the verbose boot screen, it automatically logs in and goes to a blank screen. How do I fix this issue and restore access to my Pi?
3 Answers
Here's what I would do.
Install a Debian or other Linux Virtual Machine on your Mac (VirtualBox is good for this). You'll need this to access the Linux-formatted filesystems on the SDCard.
Shut down the Raspberry Pi and remove the SDCard.
Insert the SDCard into your Mac, and load the VirtualBox VM (and install Linux on it). Then follow the instructions here to solve this exact problem by mounting the SDCard under a Linux VM and editing the authorized_keys
file or sshd_config
.
-
Both yours and Jacob's answers were great, but I felt this one was a bit more accurate from start to finish with regards to Mac OS X not being able to read the /home directory. Feb 22, 2016 at 5:32
Since you're using a Mac the solution is relatively simple.
Take the SD card out of the Raspberry Pi and put it into your Mac.
Find the file,
/home/pi/.ssh/authorized_keys
, on the appropriate partitionDelete the old public keys listed in the file
Add your new public key
Unmount the device from your Mac
Plug it into the RPi and plug it back in
edit:
It appears that I'm misinformed of the capabilities of MacOS. Looks like your best option is the same one given to Windows users. Download VirtualBox, and follow the same instructions, but from Linux instead.
-
I plugged it into my computer but there is no home directory. Bunch of files like kernel.IMG, cmdline.txt, and other executable files. Feb 22, 2016 at 4:33
-
@uioporqwerty: You're looking at the first partition of the device. I'm not a Mac user, but I was under the impression that a Mac could access both partitions, unlike Windows. Feb 22, 2016 at 4:35
-
@uioporqwerty: If you can't even access the second partition via the terminal, you should probably follow the above steps using a Linux virtual machine. Feb 22, 2016 at 4:36
-
OS X cannot read
ext4
partitions. You used to be able to use 3rd part ad-ons, but even this does not work onEl-Capitan
Feb 22, 2016 at 5:02 -
@Milliways: Yup, looks like I'm more or less just completely misinformed... Feb 22, 2016 at 5:25