Created
February 4, 2019 22:21
-
-
Save MaiLinhGroup/5c82e14b14fc708d4f6e5039b79cfc45 to your computer and use it in GitHub Desktop.
Enable ssh and bootstrap WiFi for Raspberry Pi 3 on OSX. Make it executable with "chmod +x enable_ssh_wifi_osx.sh".
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
#!/usr/bin/env bash | |
ssh_wifi() { | |
touch /Volumes/boot/ssh | |
touch wpa_supplicant.conf | |
echo "country=DE" >> wpa_supplicant.conf | |
echo "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev" >> wpa_supplicant.conf | |
echo "update_config=1" >> wpa_supplicant.conf | |
echo "network={" >> wpa_supplicant.conf | |
echo " ssid=\"$ssid\"" >> wpa_supplicant.conf | |
echo " psk=\"$psk\"" >> wpa_supplicant.conf | |
echo "}" >> wpa_supplicant.conf | |
mv wpa_supplicant.conf /Volumes/boot/wpa_supplicant.conf | |
# eject sd card after setup ssh and wifi | |
diskutil list | |
read -p "Enter disk identifier to eject the sd card: " disk | |
if [ -n $disk ]; then | |
sudo diskutil eject /dev/$disk | |
else | |
echo "Could not eject sd card, so diy." | |
fi | |
} | |
if [ -d "/Volumes/boot" ]; then | |
read -p "Enter SSID: " ssid | |
read -p "Enter PSK: " psk | |
ssh_wifi "$ssid" "$psk" | |
else | |
echo "Please insert the SD card and run the script again." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
helpful!
here is what I've added to mine..
adds support for hidden SSID,
useful in-case you use your pi as a IP-camera-hub (with ffmpeg or something),
and
WPA2-PSK
, to match what is the default in many routers now days (default isWPA-PSK
).