Last active
November 18, 2017 00:17
-
-
Save lmlsna/29055d88bcb783f53d711cd6b81baff3 to your computer and use it in GitHub Desktop.
script to enable SSH on a fresh Raspbian (Raspberry Pi) install
This file contains hidden or 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 | |
# Enables SSH on first boot by touching a blank file called `ssh` in the boot directory | |
# Requies the $disk argument (in the format /dev/sdX) to be set or passed as the fisrt command line flag. | |
disk="$disk$1" | |
if [[ -z "$disk" ]]; then | |
echo "You need to pass the install device (/dev/sdX) with the \$disk arg or as the 1st param" | |
exit 1 | |
fi | |
sync && partprobe $disk; | |
umount ${disk}{2,1}; | |
mnt=$(mktemp -d); | |
mount -t auto ${disk}2 $mnt; | |
mount -t auto ${disk}1 ${mnt}/boot; | |
touch ${mnt}/boot/ssh; | |
sync && umount ${disk}{1,2}; echo 'done'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment