LoginSignup
16
15

More than 5 years have passed since last update.

Raspberry PiをWLI-UC-GNMEで無線LANに接続する

Posted at

はじめに

Raspberry Piを無線LANに接続して、SSHでログインできるようにします。
無線LANの子機にはWLI-UC-GNMEというBUFFALOのWi-Fi子機を使います。

Raspberry PiへのOSインストールなど初期設定は済んでいるものとします。

参考: MacOSXでRasberry PiにRaspbianをインストールする

Wi-Fi子機の設定

まずはとにかくネットワークにつなげましょう。

USBに子機を挿します。
lsusbコマンドを打つと、Wi-Fi子機を認識しているはずです。

次のコマンドでWi-Fiの設定を設定ファイルに書き込みます。
SSIDとPASSPHRASEは接続したいネットワークのものを入力してください。

wpa_passphrase SSID PASSPHRASE | sudo tee -a /etc/wpa_supplicant/myhome.conf

今作ったファイルを編集します。

/etc/wpa_supplicant/myhome.conf
network={
        ssid="SSID"
        psk=hogehogehogehoge
        proto=WPA WPA2
        key_mgmt=WPA-PSK
        pairwise=CCMP TKIP
        group=CCMP TKIP
        priority=2
}

次は、/etc/network/interfacesを編集します。

サーバとして使うときなど固定IPを使いたい場合は、次のように設定します。
wlan0の部分がWi-Fiの設定です。

/etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
    address 192.168.11.99
    netmask 255.255.255.0
    network 192.168.11.0
    broadcast 192.168.11.255
    gateway 192.168.11.254
    dns-nameservers 192.168.11.100
    wireless-essid SSID
    wpa-conf /etc/wpa_supplicant/myhome.conf

DHCPを使いたい場合は、次のようにします。

/etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
    wireless-essid SSID
    wpa-conf /etc/wpa_supplicant/myhome.conf

設定ができたら、ネットワークを再起動します。

sudo service networking restart

たまにFailedと出ますが、何回かやると成功する場合もあります。
再起動できたら、適当にpingでもしてみましょう。

pi@raspberrypi ~ $ ping yahoo.co.jp
PING yahoo.co.jp (183.79.135.206) 56(84) bytes of data.
64 bytes from f1.top.vip.kks.yahoo.co.jp (183.79.135.206): icmp_req=1 ttl=56 time=27.0 ms
64 bytes from f1.top.vip.kks.yahoo.co.jp (183.79.135.206): icmp_req=2 ttl=56 time=18.2 ms
64 bytes from f1.top.vip.kks.yahoo.co.jp (183.79.135.206): icmp_req=3 ttl=56 time=19.9 ms
^C
--- yahoo.co.jp ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 18.254/21.723/27.004/3.798 ms

SSH設定

SSHの設定をします。設定というか、公開鍵を~/.ssh/authorized_keysに置いて公開鍵認証でログインできるようにするだけです。
今回はGithubから公開鍵をダウンロードしてきます。

mkdir .ssh
curl -o .ssh/authorized_keys https://github.com/nownabe.keys
chmod 600 .ssh/authorized_keys
chmod 700 .ssh

手元のPCからSSHでログインしてみます。

$ ssh pi@192.168.11.99
Linux raspberrypi 3.18.11+ #781 PREEMPT Tue Apr 21 18:02:18 BST 2015 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Aug  8 21:05:45 2015 from nownabe.local
pi@raspberrypi ~ $

ログインできました!

おわりに

これでHDMIケーブルもUSBキーボードも抜いてOKです!すっきり!! :laughing:
電源ケーブルもなんとかしたいですね :bulb:

16
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
15