public_notes/content/20240204184839 raspi4 家サーバー 作業ログ 1.md
2024-02-12 10:32:43 +09:00

4.9 KiB
Executable file
Raw Blame History

20240204184839 raspi4 家サーバー 作業ログ

#tech #raspi #server

買ったもの

  • 【国内正規代理店品】Raspberry Pi4 ModelB 4GB ラズベリーパイ4 技適対応品【RS・OKdo版】 https://amazon.co.jp/dp/B081YD3VL5

  • Smraza Raspberry Pi 4 USB-C (Type C電源、5V 3A ラズベリーACアダプター RPi 4b Model B 1GB / 2GB / 4GB/ 8GB適用 https://amazon.co.jp/dp/B07DN5V3VN

  • Flirc ラズベリーパイ4ケース シルバー https://amazon.co.jp/dp/B07WG4DW52

  • 動作せず変更予定 CFD SSD M.2 NVMe RGAX シリーズ 3D NAND TLC採用 SSD PCIe Gen3×4 (読み取り最大3100MB/S) M.2-2280 NVMe 内蔵SSD1TB CSSD-M2L1TRGAXN 国内メーカー https://amazon.co.jp/dp/B0C4NQWQ4K

  • ORICO M.2 SSDケース USB-C to NVMe M-Key / B&M KeyNvmeのみに対応 USB 3.1 Gen2 10Gbps 外付けケース ABS+アルミ材質 UASPサポート2230/2242/2260/2280 SSD対応 M.2 SSD 変換アダプタ エンクロージャ ケース 黑 M2PV-BK https://amazon.co.jp/dp/B08GC326LL

20240204 最初のセットアップ

Raspberry Pi Imagerを使ってSDカードを作成

Install Raspberry Pi OS using Raspberry Pi Imager のDownload for * で自分の環境用のRaspberry Pi Imagerをダウンロード、インストール

起動したら、

  • Raspberry PIデバイス: RASPBERRY PI4
  • OS: Raspberry Pi OS(other) -> Raspberry Pi OS Lite(64-bit)
  • ストレージ: マイクロSDカードをPCに接続して、それを選ぶ Would you like to apply OS customization settings? で「設定を編集する」ボタンを押す。
  • 一般 ホスト名、ユーザー名とパスワード、ロケールなど適切に設定
  • サービス SSHを有効にする をチェック パスワード認証を使う
  • オプション 編集せず で保存ボタンを押す。 Would you like to apply OS customization settings? で、 「はい」を選んで書き込み。

ルーターの設定

  • DHCPスタティックIP設定 を追加

起動

書きこんだらRaspi 4に挿して、LANケーブルなど繋いで起動。 wsl2上のubuntuから、sshで接続確認。

sshを公開鍵認証にする

以下はwsl2のubuntuでやる。

$ ssh-keygen -t ed25519 
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/kazbo/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):(Enterを押す)
Enter same passphrase again:(Enterを押す)
Your identification has been saved in /home/kazbo/.ssh/id_ed25519
Your public key has been saved in /home/kazbo/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256: ...  
The key's randomart image is:
+--[ED25519 256]--+
...
+----[SHA256]-----+

.ssh/に id_ed25519 id_ed25519.pub の2つのファイルができている。

$ cat .ssh/id_ed25519.pub

とやって表示される文字列

ssh-ed25519 ...

をコピーしておく。

raspi側で

$ mkdir .ssh
$ touch .ssh/authorized_keys
$ cat >> .ssh/authorized_keys
ssh-ed25519 ... (をコピペしてEnterを押す)
[ctrl+d]を押す
$ chmod 700 .ssh
$ chmod 600 .ssh/authorized_keys

接続確認。wsl側で

$ ssh -i .ssh/id_ed25519 saipi4(自分で設定したraspiのホスト名)
The authenticity of host 'saipi4 (192.168.1.100)' can't be established.
ECDSA key fingerprint is SHA256:UVgt3CY1o1JYPTf8CX5CLWV2UG6rtlvNHUQ4w6mLd8g.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'saipi4' (ECDSA) to the list of known hosts.

Linux saipi4 6.1.0-rpi7-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24) aarch64

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 Feb  4 18:47:22 2024 from 192.168.1.62

無事接続できた。 公開鍵で認証できるようになったので、パスワードログインを無効にする。

$ sudo nano /etc/ssh/ssh

# PasswordAuthentication yes と書かれている所を、先頭の#を外して、 PasswordAuthentication no にする。 $ service sshd restart でsshd再起動。

以降は

ssh saipi4

で接続できるっぽい。最初からできたかも。

cf.

OSを最新に

$ sudo apt update してから、

$ sudo apt full-upgrade
...
$ sudo reboot (最新にしたので再起動)

`

SSD bootに設定