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?

  • What do you mean for "private ssh key"? As long as I know for ssh connection you need just Pi's username@IPaddress and Pi's password. What is the output if you try to connect like this to your Pi? Feb 21, 2016 at 20:16

3 Answers 3


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.

  1. Take the SD card out of the Raspberry Pi and put it into your Mac.

  2. Find the file, /home/pi/.ssh/authorized_keys, on the appropriate partition

  3. Delete the old public keys listed in the file

  4. Add your new public key

  5. Unmount the device from your Mac

  6. Plug it into the RPi and plug it back in


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.
    – Jacobm001
    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.
    – Jacobm001
    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 on El-Capitan
    – Milliways
    Feb 22, 2016 at 5:02
  • @Milliways: Yup, looks like I'm more or less just completely misinformed...
    – Jacobm001
    Feb 22, 2016 at 5:25

Try Ctrl + Alt + F2 to go to other session.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.