UJP - 技術情報2 バックアップ : RapsberryPi3/002/FirstSetting のバックアップ差分(No.1)

Life is fun and easy!

不正IP報告数

Okan Sensor
 
メイン
ログイン
ブログ カテゴリ一覧

1: 2016-07-03 (日) 12:25:28 nobuaki ソース
Line 1: Line 1:
 +*Raspberry Pi3 初期設定 [#o4796f0c]
 +**はじめに [#p26e7211]
 +
 + Raspberry Pi3にRASPBIANをインストール後,最初に必要と思われる設定を行う.SSH接続できる様にし,piユーザとrootユーザのパスワードを設定.固定IPアドレスを定義,
 +
 +**SSH接続する [#j1050cce]
 +
 + デフォルトでSSHサーバが起動して接続できる様になっている.今回の場合は,192.168.0.3になっているが,IPアドレスを調べて,リモート接続してみる.
 + デフォルトで用意されているユーザIDのpiで接続.
 +
 + MBA13:~ ujpadmin$ ssh pi@192.168.0.3
 + The authenticity of host '192.168.0.3 (192.168.0.3)' can't be established.
 + ECDSA key fingerprint is SHA256:s/2me7eOw9yV9pHLdjMZR9gPehGSPLydsBtua2Rhx7o.
 + Are you sure you want to continue connecting (yes/no)? yes
 + Warning: Permanently added '192.168.0.3' (ECDSA) to the list of known hosts.
 + pi@192.168.0.3's password:
 +
 +パスワードはデフォルトのraspberryを入力.
 +
 + 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: Sun Jul  3 01:26:03 2016
 + pi@raspberrypi:~ $
 +
 + 接続できた.
 +
 +**piユーザとrootユーザのパスワード変更 [#v541c41a]
 +
 + piユーザは誰でも知っているパスワードなので,変更する.
 +
 + pi@raspberrypi:~ $ passwd pi
 + Changing password for pi.
 + (current) UNIX password:現在のパスワードのraspberryを入力.
 + Enter new UNIX password:新しいパスワード
 + Retype new UNIX password:新しいパスワード
 + passwd: password updated successfully
 + pi@raspberrypi:~ $
 +
 + 成功.rootユーザのパスワードも設定変更しておく.まずはsudoしてrootユーザに成り替わる.
 +
 + pi@raspberrypi:~ $ sudo su -
 + root@raspberrypi:~#
 +
 + パスワードを設定変更.
 +
 + root@raspberrypi:~# passwd root
 + Enter new UNIX password:新しいパスワード
 + Retype new UNIX password:新しいパスワード
 + passwd: password updated successfully
 + root@raspberrypi:~#
 +
 + 完了.
 +
 +**ネットワーク情報を変更 [#h5df5795]
 +
 +***ネットワークの現在設定を確認. [#y022f4c2]
 +
 + pi@raspberrypi:~ $ /sbin/ifconfig -a
 + eth0      Link encap:Ethernet  HWaddr b8:65:ab:6c:27:eb
 +           inet addr:192.168.0.3  Bcast:192.168.0.255  Mask:255.255.255.0
 +           inet6 addr: fe80::7b2b:2fe4:1c2d:84f4/64 Scope:Link
 +           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 +           RX packets:1627 errors:0 dropped:3 overruns:0 frame:0
 +           TX packets:904 errors:0 dropped:0 overruns:0 carrier:0
 +           collisions:0 txqueuelen:1000
 +           RX bytes:609978 (595.6 KiB)  TX bytes:131135 (128.0 KiB)
 +
 + lo        Link encap:Local Loopback
 +           inet addr:127.0.0.1  Mask:255.0.0.0
 +           inet6 addr: ::1/128 Scope:Host
 +           UP LOOPBACK RUNNING  MTU:65536  Metric:1
 +           RX packets:200 errors:0 dropped:0 overruns:0 frame:0
 +           TX packets:200 errors:0 dropped:0 overruns:0 carrier:0
 +           collisions:0 txqueuelen:1
 +           RX bytes:16656 (16.2 KiB)  TX bytes:16656 (16.2 KiB)
 +
 + wlan0    Link encap:Ethernet  HWaddr b8:27:eb:39:30:fe
 +           inet6 addr: fe80::a113:ce32:1dd1:5d6/64 Scope:Link
 +           UP BROADCAST MULTICAST  MTU:1500  Metric:1
 +           RX packets:497 errors:0 dropped:497 overruns:0 frame:0
 +           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 +           collisions:0 txqueuelen:1000
 +           RX bytes:201656 (196.9 KiB)  TX bytes:0 (0.0 B)
 +
 + pi@raspberrypi:~ $
 +
 + WLANも認識しているな...
 +
 +***固定IPアドレスの設定 [#ad0e6dd6]
 +
 + /etc/dhcpcd.confにIPアドレス・サブネットマスク,ゲートウェイアドレス,そしてDNSサーバを記載することで,固定IPアドレスを設定することができる.
 + まずは,現在設定を確認.
 +
 + root@raspberrypi:~# grep -v "^#" /etc/dhcpcd.conf
 +
 +
 + hostname
 +
 + clientid
 +
 + persistent
 +
 + option rapid_commit
 +
 + option domain_name_servers, domain_name, domain_search, host_name
 + option classless_static_routes
 + option ntp_servers
 +
 + require dhcp_server_identifier
 +
 + slaac private
 +
 + nohook lookup-hostname
 + root@raspberrypi:~#
 +
 + 設定を投入する.
 +
 + root@raspberrypi:~# echo interface eth0 >> /etc/dhcpcd.conf
 + root@raspberrypi:~# echo static ip_address=192.168.0.241/24 >> /etc/dhcpcd.conf
 + root@raspberrypi:~# echo static routers=192.168.20.1 >> /etc/dhcpcd.conf
 + root@raspberrypi:~# echo static domain_name_servers=192.168.20.1 >> /etc/dhcpcd.conf
 + root@raspberrypi:~#
 +
 + ホスト名編集前にバックアップを行う.
 +
 + root@raspberrypi:~# cp -f /etc/dhcpcd.conf /etc/dhcpcd.conf.bak
 + root@raspberrypi:~#
 +
 + ホスト名を設定する.この例の場合,commetというホスト名をつける.
 +
 + root@raspberrypi:~# cat /etc/dhcpcd.conf.bak | sed -e 's/^hostname/hostname commet/g' > /etc/dhcpcd.conf
 + root@raspberrypi:~#
 +
 + 投入した設定を確認.
 +
 + root@raspberrypi:~# grep -v "^#" /etc/dhcpcd.conf
 +
 +
 + hostname commet
 +
 + clientid
 +
 + persistent
 +
 + option rapid_commit
 +
 + option domain_name_servers, domain_name, domain_search, host_name
 + option classless_static_routes
 + option ntp_servers
 +
 + require dhcp_server_identifier
 +
 + slaac private
 +
 + nohook lookup-hostname
 + interface eth0
 + static ip_address=192.168.0.241/24
 + static routers=192.168.20.1
 + static domain_name_servers=192.168.20.1
 + root@raspberrypi:~#
 +
 +***設定した固定IPアドレスを有効化する [#y014f61b]
 +
 + root@raspberrypi:~# ifdown eth0;sleep 1;ifdown eth0 &
 + ifdown: interface eth0 not configured
 + [1] 1538
 + root@raspberrypi:~#
 +
 + interfaceファイルに記載が無いのでifdown/ifupコマンドは利用できない模様.手っ取り早く再起動してみる.
 +
 + root@raspberrypi:~# reboot
 + Connection to 192.168.0.3 closed by remote host.
 + Connection to 192.168.0.3 closed.
 + MBA13:~ ujpadmin$
 +
 + 変更後のIPアドレスで接続してみる.
 +
 + MBA13:~ ujpadmin$ ssh pi@192.168.0.241
 + The authenticity of host '192.168.0.241 (192.168.0.241)' can't be established.
 + ECDSA key fingerprint is SHA256:s/2jMe7eOds9pua2RhxwPHLdhBt9yVGSPZR9gemLy7o.
 + Are you sure you want to continue connecting (yes/no)? yes
 + Warning: Permanently added '192.168.0.241' (ECDSA) to the list of known hosts.
 + pi@192.168.0.241's password:先ほど設定したパスワード
 +
 + 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: Sun Jul  3 02:45:04 2016
 + pi@raspberrypi:~ $
 +
 + 設定を確認する.
 +
 + pi@raspberrypi:~ $ ifconfig -a
 + eth0      Link encap:Ethernet  HWaddr b8:65:ab:6c:27:eb
 +           inet addr:192.168.0.241  Bcast:192.168.0.255  Mask:255.255.255.0
 +           inet6 addr: fe80::7b2b:2fe4:1c2d:84f4/64 Scope:Link
 +           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 +           RX packets:145 errors:0 dropped:0 overruns:0 frame:0
 +           TX packets:108 errors:0 dropped:0 overruns:0 carrier:0
 +           collisions:0 txqueuelen:1000
 +           RX bytes:11545 (11.2 KiB)  TX bytes:15366 (15.0 KiB)
 +
 + lo        Link encap:Local Loopback
 +           inet addr:127.0.0.1  Mask:255.0.0.0
 +           inet6 addr: ::1/128 Scope:Host
 +           UP LOOPBACK RUNNING  MTU:65536  Metric:1
 +           RX packets:128 errors:0 dropped:0 overruns:0 frame:0
 +           TX packets:128 errors:0 dropped:0 overruns:0 carrier:0
 +           collisions:0 txqueuelen:1
 +           RX bytes:10368 (10.1 KiB)  TX bytes:10368 (10.1 KiB)
 +
 + wlan0    Link encap:Ethernet  HWaddr b8:27:eb:39:30:fe
 +           inet6 addr: fe80::a113:ce32:1dd1:5d6/64 Scope:Link
 +           UP BROADCAST MULTICAST  MTU:1500  Metric:1
 +           RX packets:26 errors:0 dropped:26 overruns:0 frame:0
 +           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
 +           collisions:0 txqueuelen:1000
 +           RX bytes:11233 (10.9 KiB)  TX bytes:0 (0.0 B)
 +
 + pi@raspberrypi:~ $
 +
 + 接続できた.


トップ   差分 バックアップ 複製 名前変更 リロード   ページ新規作成 全ページ一覧 単語検索 最新ページの一覧   ヘルプ   最新ページのRSS 1.0 最新ページのRSS 2.0 最新ページのRSS Atom
Counter: 2028, today: 2, yesterday: 0

広告スペース
Google