2018年1月29日月曜日

Raspberry Pi の無線 LAN まわりの設定

raspi-config で無線 LAN の設定をしたのですが、設定ファイルを見るとパスワードがそのまま記録されていました。 かなり気になるので修正して、ついでに固定 IP にしました。

環境

  • Raspberry Pi 3 Model B
  • Raspbian Stretch Lite

無線 LAN パスワードがそのまま記録されていたので修正

パスワードがそのまま記録されているのはこのファイルです。

/etc/wpa_supplicant/wpa_supplicant.conf

まずはこのファイルから関連の箇所をごっそり削除

改めて SSID とパスワードを設定

$ wpa_passphrase MY_SSID | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf
  • 標準入力からパスワードを入力してリターンキー

この時点で以下のようになりました。

$ cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=JP

# reading passphrase from stdin
network={
        ssid="MY_SSID"
        #psk="MY_PASSWORD"
        psk=da2beb2e20bc43948554653b92b7c79c589926b0f91b0cd16a7dacc2e2b4dc95
}
  • いろいろいじったのが原因か、一般ユーザーでも見ることができてしまっています。

以下の行を削除

#psk="MY_PASSWORD"

一般ユーザーが中身を見たり修正できないようにしておきました。

$ sudo chmod 640 /etc/wpa_supplicant/wpa_supplicant.conf
$ ls -la /etc/wpa_supplicant/wpa_supplicant.conf
-rw-r----- 1 root root 214 Jan 29 23:25 /etc/wpa_supplicant/wpa_supplicant.conf

無線 LAN に固定 IP アドレスを設定

以下のように IP アドレス情報追加

echo "
interface wlan0
static ip_address=192.168.0.11/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1 8.8.8.8
" \
| sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf

Raspberry Pi 再起動


4 件のコメント:

  1. I like this topic.This site has lots of advantage.I found many interesting things from this site. It helps me in many ways.Thanks for posting this again.
    BCOM 1st, 2nd & Final Year TimeTable 2020
    Maharaja Surajmal Brij University BCOM TimeTable 2020

    返信削除
  2. I?m impressed, I must say. Really rarely do I encounter a blog that?s both educative and entertaining, and let me tell you, you have hit the nail on the head. Your idea is outstanding; the issue is something that not enough people are speaking intelligently about. I am very happy that I stumbled across this in my search for something relating to this.

    Jaipur tour package by Car

    返信削除