diff --git a/content/20240204184839 raspi4 家サーバー 作業ログ.md b/content/20240204184839 raspi4 家サーバー 作業ログ.md new file mode 100755 index 0000000..15eaa59 --- /dev/null +++ b/content/20240204184839 raspi4 家サーバー 作業ログ.md @@ -0,0 +1,43 @@ +# 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 Key(Nvmeのみ)に対応 USB 3.1 Gen2 10Gbps 外付けケース ABS+アルミ材質 UASPサポート2230/2242/2260/2280 SSD対応 M.2 SSD 変換アダプタ エンクロージャ ケース 黑 M2PV-BK https://amazon.co.jp/dp/B08GC326LL + + + +## 20240204 最初のセットアップ + +[[20240204221756 Raspberry Pi Imagerを使ってSDカードを作成]] + +### ルーターの設定 +- DHCPスタティックIP設定 を追加 + +### 起動 +microSDに必要なデータを書きこんだら、Raspi 4に挿して、LANケーブルなど繋いで起動。 +wsl2上のubuntuから、sshで接続確認。(名前とパスワード。後で無効化する) + +ここまでできたら、SSD bootの設定をする。 + +[[20240204221948 raspberry piをSSD bootに設定]] + +[[20240204222141 sshを公開鍵認証にする]] + + + +### OSを最新に + +`$ sudo apt update` +してから、 +``` +$ sudo apt full-upgrade +... +$ sudo reboot (最新にしたので再起動) +``` +` diff --git a/content/20240204222141 sshを公開鍵認証にする.md b/content/20240204222141 sshを公開鍵認証にする.md new file mode 100755 index 0000000..445d880 --- /dev/null +++ b/content/20240204222141 sshを公開鍵認証にする.md @@ -0,0 +1,85 @@ +# 20240204222141 sshを公開鍵認証にする +#raspberrypi #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/sshd_config +``` +` # PasswordAuthentication yes` +と書かれている所を、先頭の#を外して、 +`PasswordAuthentication no` +にする。 +`$ sudo service sshd restart` +でsshd再起動。 + +以降は +``` +ssh saipi4 +``` +で接続できるっぽい。最初からできたかも。. + +cf. +- [「よく分かる公開鍵認証」~初心者でもよくわかる!VPSによるWebサーバー運用講座(2) | さくらのナレッジ](https://knowledge.sakura.ad.jp/3543/) +- [SSH公開鍵認証で接続するまで #SSH - Qiita](https://qiita.com/kazokmr/items/754169cfa996b24fcbf5) +- [気付けばssh-keygen -t の後にrsaでなくed25519と打つことが推奨されていた | ABC DX Tech Blog](https://tech.asahi.co.jp/posts/20231005-bbf6) \ No newline at end of file