Setup Raspberry Pi Using a Mac
Basic Infomation
- OS: macOS High Sierra
- Raspberry Pi device: Raspberry Pi model B, 1GB RAM, 802.11b/g/n, Wireless LAN, Bluetooth 4.1
- Raspberry OS: Raspbian stretch lite 2018-04-18
- SD card: SanDisk Ultra 32GB
Downloading Raspbian stretch lite image
- 可至Raspbian下載最新的Raspbian stretch lite
|
|
Burning Raspbian image to SD card
|
|
Launching Raspbian
- 插上SD card
- 接上HDMI螢幕
- 接上Micro USB電源線
- 使用預設帳號密碼登入: pi/raspberry
進入Raspbian設定頁面:
1pi@raspberrypi:~ $ sudo raspi-config變更登入密碼
開啟SSH server
開啟Wifi
12345678910111213141516pi@raspberrypi:~ $ sudo vi /etc/network/interfacesallow-hotplug wlan0iface wlan0 inet manualwpa-conf /etc/wpa_supplicant/wpa_supplicant.confpi@raspberrypi:~ $ sudo vi /etc/wpa_supplicant/wpa_supplicant.confctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdevupdate_config=1country=TWpi@raspberrypi:~ $ sudo systemctl enable wpa_supplicant.servicepi@raspberrypi:~ $ sudo reboot## 須先重新登入raspberrypi@raspberrypi:~ $ sudo raspi-config
Launching Raspbian Without HDMI Monitor
此步驟可以達成在沒有HDMI螢幕的情況下,透過ssh經由Wifi啟動並設置Raspbian
在將Raspbian image寫入SD card後,進行下述操作
1234567891011121314151617MacBook-Pro:raspbian ~ user$ cd /Volumes/boot## 為之後要使用的ssh命令建立檔案MacBook-Pro:boot chung$ touch ssh## 設定Wifi的配置## NATWORK_NAME: Wifi device的名稱## YOUR_PASSWORD: Wifi device的密碼MacBook-Pro:boot chung$ vim wpa_supplicant.confctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdevupdate_config=1country=GBnetwork={ssid="NATWORK_NAME"psk="YOUR_PASSWORD"}將SD card插入Raspbian
- 接上Micro USB電源線
- 取得Raspbian的IP,有以下2種方式:
- 至Wifi device的管理頁面查看新連上的裝置所被配置的IP
- 使用網路嗅探工具,例如nmap,查看相同Wifi環境下的IP
- 使用ssh以及預設帳號密碼登入: pi/raspberry