0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【備忘録】ラズパイ初期化時に行うこと

Last updated at Posted at 2025-02-18

環境

Raspberry Pi Imagerでラズパイ4にUbuntu Serverをインストールしている環境。

Imager側でSSH設定やWi-Fi設定をしておく。

(キーボード配列)

JIS US
Shift + 2 @
; ;
Shift + ; :
@ [
[ ]
Shift + @ {
Shift + [ }

パッケージマネージャの設定

sudo apt update && sudo apt upgrade -y

SSH接続の設定

~いつも使っているPC側の設定~
ssh-keygen -t rsa -b 4096
scp <ローカルの公開鍵のパス> <サーバーのユーザー名>@<サーバーのIPアドレス>:~/.ssh/

~一旦パスワードでサーバーに接続~

cat <サーバーの公開鍵のパス> >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

sudo vi /etc/ssh/sshd_config
~変更~
sudo systemctl stop ssh
sudo systemctl start ssh  # なぜかrestartだと反映されなかtt

プライベートIPアドレスを固定

sudo vi /etc/netplan/50-cloud-init.yaml
/etc/netplan/50-cloud-init.yaml
network:
  version: 2
  renderer: networkd  # なぜかデフォルトだとwifisの中に入っていたから修正
  wifi:
    wlan0:  # デフォルトで入っている
      access-points:
        hogehoge:  # デフォルトで入っている
          password: hogehoge  # デフォルトで入っている
      dhcp4: false
      dhcp6: false
      addresses:
        - 192.168.aaa.bbb/24
      routes:
        - to: default
          via: 192.168.aaa.ccc
      nameservers:
        addresses:
          - 192.168.aaa.ccc
          - 8.8.8.8
          - 8.8.4.4
sudo netplan apply

ファイアウォールの設定

sudo ufw enable
sudo ufw allow <port-id>
(sudo ufw delete allow <port-id>)

Nginxの設定

sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx

Let's Encryptの設定

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d example.com -d www.example.com
sudo certbot renew --dry-run

USBメモリのマウント

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?