インストール完了後の作業をメモ程度に...
無線LANアクセスの設定をする
# vi /etc/wpa_supplicant/wpa_supplicant.conf
... 最後尾に追加する
network={
ssid="SSID名"
scan_ssid=1 # ステルスAPに接続する
key_mgmt=WPA-PSK
proto=WPA2
pairwise=CCMP TKIP
group=CCMP TKIP
psk="アクセスキー"
}
無線LANに固定IPアドレスを設定する
# vi /etc/dhcpcd.conf
... 最後尾に追加
interface wlan0
static ip_address=192.168.1.20/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
公開鍵認証にする
鍵ペアを作る
macでの例
% ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/userName/.ssh/id_rsa): "ENTER(鍵ペアの生成場所を変えるときはパスを入力)"
Enter passphrase (empty for no passphrase): "パスフレーズ"
Enter same passphrase again: "パスフレーズの再入力"
Your identification has been saved in /Users/userName/.ssh/id_rsa.
Your public key has been saved in /Users/userName/.ssh/id_rsa.pub.
...略
指定したパスに鍵ペア「id_rsa」「id_rsa.pub」ができる。
公開鍵をraspberry piに転送する
scpを使って「id_rsa.pub」をraspberry piのログイン対象ユーザホームディレクトリ配下に転送する。
% cd ~/.ssh
% scp ./id_rsa.pub userName@192.168.1.20:
rasberry piでssh設定をする
ログイン対象ユーザで公開鍵を設定する。
$ cd ~/
$ ls
id_rsa.pub
$ mkdir .ssh
$ mv id_rsa.pub .ssh/authorized_keys
$ chmod 700 .ssh/
$ chmod 600 .ssh/authorized_keys
sshdの設定
sshdの設定を修正してサービスを再起動する
$ sudo vi /etc/ssh/sshd_config
...以下の設定を探し、修正する
PermitRootLogin no
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
PasswordAuthentication no
$ sudo /etc/init.d/ssh restart
※ 念のため、今開いているsshコンソールはログアウトせずに置く
sshクライアント側の設定
macの~/.ssh/configを設定
% vi ~/.ssh/config
... raspiのセクションを追加する
Host raspi
HostName 192.168.1.20
Port 22
User userName
IdentityFile ~/.ssh/id_rsa
loginの確認
% ssh raspi
Last login: Mon May 2 09:32:45 2016 from 192.168.1.11
userName@hostName:~ $