How can I regain SSH access if I:
- Have physical access to the device
- Do not have a way of plugging in an external monitor (or serial console)
- Was previously using SSH
How can I regain SSH access if I:
Simple:
If you were using SSH previously, you should be presented with a remote terminal. This just worked for me - enjoy.
In Linux, you can use the following to append one file to another: cat source_file >> detination_file
. For me, appending my SSH public key was as simple as: cat ~/.ssh/id_rsa.pub >> /media/rootfs/home/pi/authorized_keys
; however, be sure to check the result - sometimes there's a line break missing, and you'll need to insert one manually.
If you've got the SD card mounted on some other machine, you need to know two things:
With these two, the location is: (SD card)/(path to home folder). For me on Pop OS!, this is /media/rootfs/home/pi/authorized_keys
.ssh
directory on the SD card must have be rwx for user ONLY (700)You can run these commands to set permissions correctly:
cd /media/rootfs/home/pi
chmod 700 .ssh
chmod 600 .ssh/authorized_keys