ラベル Ubuntu の投稿を表示しています。 すべての投稿を表示
ラベル Ubuntu の投稿を表示しています。 すべての投稿を表示

2026年7月4日土曜日

codex を Ubuntu で動かす場合のサンドボックス設定

codex を Ubuntu で動かす場合のサンドボックス設定

概要

自動化する場合には書き込めるように codex がサンドボックスを作成できるようにしてあげる必要があります

環境

  • Ubuntu 24.04
  • codex 0.142.5

主なエラー

Unfortunately, I **cannot execute any commands** in this environment — the sandbox is rejecting all shell execution with:

bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted


This means I cannot:
- Read the actual file contents
- Apply patches
- Run tests

Could you check if there's a sandbox configuration issue? Once commands can run, I can implement the fix directly. Alternatively, if you can share the contents of the two files, I can produce the exact patch needed.
Codex's Linux sandbox uses bubblewrap and needs access to create user namespaces.

対処方法

  • sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0

以下で確認し 0 になっていれば OK です

  • sudo sysctl kernel.apparmor_restrict_unprivileged_userns
0

インスタンスの再起動などは不要です

最後に

danger-full-access は可能な限りやめましょう
名前的にもやばいオプション名なので

参考サイト

2026年3月29日日曜日

sshd でチャレンジレスポンス認証を試す

sshd でチャレンジレスポンス認証を試す

概要

前回 Ubuntu + pam の設定を行いました

チャレンジレスポンス認証は通常のパスワード認証と毎回違うパスワードで ssh ログインさせたりすることができます
OTP や外部の認証サーバと連携したりもできます

今回は簡単な問題をシェルスクリプトで作成しその問題が正解なら認証 OK とします

環境

  • macOS 26.3.1
  • docker 29.3.0
    • Ubuntu 24.04

pam.d/ssh

# --- Auth Phase ---
# 1. クイズを表示
auth       required     pam_echo.so info Challenge: 3 + 5 = ?

# 2. スクリプト判定(8 以外ならここで拒否される)
auth       required     pam_exec.so expose_authtok /usr/local/bin/math_challenge.sh

# 3. 資格情報 (setcred) を与えるためのモジュール
# 前のステップが required なので、ここには「8」と打った時しか到達しません。
# これを入れることで pam_setcred(): Permission denied を防ぎます。
auth       required     pam_permit.so


# --- Account & Session Phase ---
account    required     pam_permit.so

session    required     pam_unix.so
session    required     pam_env.so
# session  required     pam_loginuid.so  # Dockerでは引き続きコメントアウト

math_challenge.sh

#!/bin/bash
# 入力を読み取る
read -r USER_INPUT

# 判定(xargsで空白を除去)
ANSWER=$(echo "$USER_INPUT" | xargs)

if [ "$ANSWER" = "8" ]; then
    # 成功時は何も出力せず exit 0
    exit 0
else
    # 失敗時はデバッグ用に標準エラーへ(docker logsで見れる)
    echo "Auth Failed: Input was '$ANSWER'" >&2
    exit 1
fi

Dockerfile

FROM ubuntu:24.04

RUN apt-get update && \
    apt-get install -y openssh-server && \
    mkdir /var/run/sshd

# ユーザー作成
RUN useradd -m -s /bin/bash testuser && echo "testuser:testpass" | chpasswd

# 既存設定をリセットし、必要な設定だけを新規作成
RUN rm -rf /etc/ssh/sshd_config.d/* && \
    echo "Port 22" > /etc/ssh/sshd_config && \
    echo "ListenAddress 0.0.0.0" >> /etc/ssh/sshd_config && \
    echo "PermitRootLogin no" >> /etc/ssh/sshd_config && \
    echo "KbdInteractiveAuthentication yes" >> /etc/ssh/sshd_config && \
    echo "PasswordAuthentication no" >> /etc/ssh/sshd_config && \
    echo "UsePAM yes" >> /etc/ssh/sshd_config

# 認証スクリプトをコピー
COPY math_challenge.sh /usr/local/bin/math_challenge.sh
RUN chmod +x /usr/local/bin/math_challenge.sh

# PAM設定を上書き
COPY pam.d/sshd /etc/pam.d/sshd

# (重要) CHALLENGE-RESPONSEを有効化
RUN sed -i 's/KbdInteractiveAuthentication no/KbdInteractiveAuthentication yes/' /etc/ssh/sshd_config

EXPOSE 22

CMD ["/usr/sbin/sshd", "-D", "-e"]

compose.yaml

services:
  ssh:
    build: .
    container_name: ssh-challenge
    ports:
      - "2222:22"

動作確認

  • docker compose up -d --build
  • ssh -o PreferredAuthentications=keyboard-interactive testuser@localhost -p 2222

これで「8」と入力すればログインできるようになります
それ以外はログインエラーになります
さすがにチャレンジするパスワードが簡単すぎるので本当はもっと複雑な問題にします

最後に

Ubuntu24.04 でチャレンジレスポンス認証を試してみました
pam と連携することでより複雑なチャレンジレスポンス認証が実装できます

あとはこのスクリプトをより改良して外部の認証機構と連携したりすることができます

2026年3月28日土曜日

Ubuntu で pam 認証を有効にする

Ubuntu で pam 認証を有効にする

概要

PAM (Pluggable Authentication Modules) は通常の sshd 認証と違い外部の認証機構などを使って認証する仕組みです
sshd と組み合わせることで OTP などを実現できます
今回は Ubuntu 24.04 で pam を設定する方法を紹介します

環境

  • macOS 26.3.1
  • docker 29.3.0
    • Ubuntu 24.04

pam.d/sshd

# PAM構成の基本
auth       required     pam_unix.so nullok_secure
account    required     pam_unix.so
session    required     pam_unix.so
session    required     pam_loginuid.so

Dockerfile

FROM ubuntu:24.04

RUN apt-get update && \
    apt-get install -y openssh-server && \
    mkdir /var/run/sshd

# ユーザー作成
RUN useradd -m -s /bin/bash testuser && echo "testuser:testpass" | chpasswd

# 既存設定をリセットし、必要な設定だけを新規作成
RUN rm -rf /etc/ssh/sshd_config.d/* && \
    echo "Port 22" > /etc/ssh/sshd_config && \
    echo "ListenAddress 0.0.0.0" >> /etc/ssh/sshd_config && \
    echo "PermitRootLogin no" >> /etc/ssh/sshd_config && \
    echo "KbdInteractiveAuthentication yes" >> /etc/ssh/sshd_config && \
    echo "PasswordAuthentication no" >> /etc/ssh/sshd_config && \
    echo "UsePAM yes" >> /etc/ssh/sshd_config

# PAM設定コピー
COPY pam.d/sshd /etc/pam.d/sshd

EXPOSE 22

CMD ["/usr/sbin/sshd", "-D"]

compose.yaml

services:
  ssh:
    build: .
    container_name: ssh-challenge
    ports:
      - "2222:22"

動作確認

  • docker compose up -d --build
  • ssh -o PreferredAuthentications=keyboard-interactive testuser@localhost -p 2222

最後に

Ubuntu24.04 の sshd の場合設定が少し特殊なので注意しましょう
基本はデフォルトを削除し新規に作成するのが確実です

次回は pam を使ってチャレンジレスポンス認証を試します

2026年1月20日火曜日

Ubuntu24.04 に MySQL8.4 をインストールする方法

Ubuntu24.04 に MySQL8.4 をインストールする方法

概要

apt でインストールできます
ついでに unattended-upgrade にも対応しておきます

環境

  • Ubuntu 24.04
  • MySQL 8.4.7

インストール方法

curl -LO https://dev.mysql.com/get/mysql-apt-config_0.8.36-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.36-1_all.deb
sudo apt -y update
sudo apt -y install mysql-server

確認項目

  • root パスワードの設定
  • 既存の設定ファイル (my.cnf など) がある場合は上書きするか

動作確認

  • dpkg -l | grep 'mysql'
ii  default-libmysqlclient-dev:amd64       1.1.0build1                             amd64        MySQL database development files (metapackage)
ii  libmysqlclient-dev                     8.4.7-1ubuntu24.04                      amd64        MySQL development headers
ii  libmysqlclient24:amd64                 8.4.7-1ubuntu24.04                      amd64        MySQL shared client libraries
ii  mysql-apt-config                       0.8.36-1                                all          Auto configuration for MySQL APT Repo.
ii  mysql-client                           8.4.7-1ubuntu24.04                      amd64        MySQL Client meta package depending on latest version
ii  mysql-common                           8.4.7-1ubuntu24.04                      amd64        Common files shared between packages
ii  mysql-community-client                 8.4.7-1ubuntu24.04                      amd64        MySQL Client
ii  mysql-community-client-core            8.4.7-1ubuntu24.04                      amd64        MySQL Client Core Binaries
ii  mysql-community-client-plugins         8.4.7-1ubuntu24.04                      amd64        MySQL Client plugin
ii  mysql-community-server                 8.4.7-1ubuntu24.04                      amd64        MySQL Server
ii  mysql-community-server-core            8.4.7-1ubuntu24.04                      amd64        MySQL Server Core Binaries
ii  mysql-server                           8.4.7-1ubuntu24.04                      amd64        MySQL Server meta package depending on latest version

unattended-upgrade

  • grep -e 'Origin:' -e 'Suite:' /var/lib/apt/lists/repo.mysql.com_apt_ubuntu_dists_noble_*
/var/lib/apt/lists/repo.mysql.com_apt_ubuntu_dists_noble_InRelease:Origin: MySQL
  • sudo vim /etc/apt/apt.conf.d/58unattended-upgrades-mysql-packages
Unattended-Upgrade::Allowed-Origins {
        "MySQL:noble";
};

最後に

8.0 は 2026/04 で EOL なのでアップグレードしましょう

参考サイト

2026年1月14日水曜日

bpftrace で実行されたコマンドの親プロセスを特定する

bpftrace で実行されたコマンドの親プロセスを特定する

概要

例えば内部で curl を実行している親プロセスを特定する場合を紹介します

環境

  • Ubuntu 24.04
  • bpftrace 0.20.2

コマンド

sudo bpftrace -e '
tracepoint:syscalls:sys_enter_execve
/str(args->filename) == "/usr/bin/curl"/
{
    printf("curl executed! pid=%d comm=%s filename=%s\n",
        pid, comm, str(args->filename));
}
'

最後に

なぞのエージェントやサービスをインストールすると意図しないコマンドなどを実行することがあるので親プロセスを特定して問題ないことを確認しましょう

2025年12月17日水曜日

fail2ban で ban 情報を永続化する方法

fail2ban で ban 情報を永続化する方法

概要

これまでの方法だと docker compose down -> up -d すると ban 情報もクリアされてしまうので永続化する方法を紹介します

環境

  • Ubuntu 24.04
  • docker
  • linuxserver/fail2ban 1.1.0-r2-ls26
  • fail2ban 1.1.0

修正箇所

  • /config/fail2ban/fail2ban.sqlite3 を永続化する
  • fail2ban.sqlite3 をホスト側に先に作成する (ファイルがないとディレクトリマウントになり fail2ban の起動に失敗するため)

前回からの差分

先に

  • mkdir data
  • touch data/fail2ban.sqlite3

をしておきます
そして以下を書き換えて down -> up -d すれば OK です

diff --git a/compose.yaml b/compose.yaml
index 7a8a33f..5381790 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -20,6 +20,7 @@ services:
       - ./config/jail.local:/config/fail2ban/jail.d/jail.local
       - ./config/filter.d/nginx-404.conf:/config/fail2ban/filter.d/nginx-404.conf
       - ./config/action.d/slack.conf:/config/fail2ban/action.d/slack.conf
+      - ./data/fail2ban.sqlite3:/config/fail2ban/fail2ban.sqlite3
       - ./nginx/log:/remotelogs/nginx:ro  # nginxログを読み取り専用で監視
     environment:
       - PUID=1000  # 自身のユーザIDとグループIDに合わせて変更 (config/ 配下の権限がコンテナ側のユーザIDで変更されてしまうため編集ができなくなる)

最後に

sqlite3 のファイルを保持しましょう
down 中は解放状態になるので注意しましょう

2025年12月16日火曜日

fail2ban だけ network_mode: host で動作させる方法

fail2ban だけ network_mode: host で動作させる方法

概要

前回の続きです
なぜか nginx も network_mode: host にしていたので nginx は docker ネットワーク上で動作させます

環境

  • Ubuntu 24.04
  • docker
  • linuxserver/fail2ban 1.1.0-r2-ls26
  • fail2ban 1.1.0

修正箇所

  • jail.local の chain を DOCKER-USER に変更
  • nginx コンテナの network_mode を削除し ports でバインドするように変更

前回からの差分

diff --git a/compose.yaml b/compose.yaml
index 1f4124c..7a8a33f 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -2,7 +2,9 @@ services:
   nginx:
     image: nginx:latest
     container_name: nginx
-    network_mode: host
+    ports:
+      - "80:80"
+      - "443:443"
     volumes:
       - ./nginx/log:/var/log/nginx  # このログをfail2banで監視
     restart: unless-stopped
diff --git a/config/jail.local b/config/jail.local
index 82c38b7..3e40cb0 100644
--- a/config/jail.local
+++ b/config/jail.local
@@ -78,7 +78,7 @@ action  = %(action_)s
 [nginx-404]
 # Custom filter to detect excessive 404 errors
 enabled  = true
-chain    = INPUT
+chain    = DOCKER-USER
 port     = http,https
 filter   = nginx-404
 logpath  = /remotelogs/nginx/access.log

最後に

chain は iptables の chain に紐づいています
なぜ最初からこうしなかったのだろうか

2025年12月15日月曜日

fail2ban で ban の際に slack に通知する

fail2ban で ban の際に slack に通知する

概要

前回続きです
ban になったら slack に通知するようにしてみました

環境

  • Ubuntu 24.04
  • docker
  • linuxserver/fail2ban 1.1.0-r2-ls26
  • fail2ban 1.1.0

compose.yaml

ユーザの権限部分など少し変更しています
作成したアクションの設定ファイルもマウントするようにしています

services:
  nginx:
    image: nginx:latest
    container_name: nginx
    network_mode: host
    volumes:
      - ./nginx/log:/var/log/nginx  # このログをfail2banで監視
    restart: unless-stopped

  fail2ban:
    image: linuxserver/fail2ban:latest
    container_name: fail2ban
    network_mode: host
    cap_add:
      - NET_ADMIN # BANに必須
      - NET_RAW   # BANに必須
    volumes:
      - ./config/jail.local:/config/fail2ban/jail.d/jail.local
      - ./config/filter.d/nginx-404.conf:/config/fail2ban/filter.d/nginx-404.conf
      - ./config/action.d/slack.conf:/config/fail2ban/action.d/slack.conf
      - ./nginx/log:/remotelogs/nginx:ro  # nginxログを読み取り専用で監視
    environment:
      - PUID=1000  # 自身のユーザIDとグループIDに合わせて変更 (config/ 配下の権限がコンテナ側のユーザIDで変更されてしまうため編集ができなくなる)
      - PGID=122
      - TZ=Asia/Tokyo
      - VERBOSITY=-vv
    restart: unless-stopped

./config/jail.conf

nginx-404 サービスの action に slack を追加します

[DEFAULT]

# "bantime.increment" allows to use database for searching of previously banned ip's to increase a
# default ban time
bantime.increment = true

# "bantime.maxtime" is the max number of seconds using the ban time can reach (doesn't grow further)
bantime.maxtime = 5w

# "bantime.factor" is a coefficient to calculate exponent growing of the formula or common multiplier
bantime.factor = 24

# "bantime" is the number of seconds that a host is banned.
bantime = 1h

# A host is banned if it has generated "maxretry" during the last "findtime"
# seconds.
findtime = 24h

# "maxretry" is the number of failures before a host get banned.
maxretry = 5

# Prevents banning LAN subnets
ignoreip    = 127.0.0.1/8 ::1
              10.0.0.0/8
              172.16.0.0/12
              192.168.0.0/16

# The ban action "iptables-multiport" (default) should work for most
# The ban action "iptables-allports" can be used if multiport causes issues
banaction = iptables-multiport
banaction_allports = iptables-allports

# Read https://github.com/sebres/PoC/blob/master/FW.IDS-DROP-vs-REJECT/README.md before changing block type
# The block type "REJECT --reject-with icmp-port-unreachable" (default behavior) should respond to, but then instantly reject connection attempts
# The block type "DROP" should not respond to connection attempts, resulting in a timeout
#banaction = iptables-multiport[blocktype=DROP]

# Add additional actions
action  = %(action_)s

# [sshd]
# configuration inherits from jail.conf
# enabled = true
# chain   = INPUT
# action  = %(action_)s

[nginx-http-auth]
# configuration inherits from jail.conf
enabled = true
chain   = DOCKER-USER
action  = %(action_)s

[nginx-badbots]
# configuration inherits from jail.d/nginx-badbots.conf 
enabled = true
chain   = DOCKER-USER
action  = %(action_)s

[nginx-botsearch]
# configuration inherits from jail.conf
enabled = true
chain   = DOCKER-USER
action  = %(action_)s

[nginx-deny]
# configuration inherits from jail.d/nginx-deny.conf
enabled = true
chain   = DOCKER-USER
action  = %(action_)s

[nginx-unauthorized]
# configuration inherits from jail.d/nginx-unauthorized.conf
enabled = true
chain   = DOCKER-USER
action  = %(action_)s

[nginx-404]
# Custom filter to detect excessive 404 errors
enabled  = true
chain    = INPUT
port     = http,https
filter   = nginx-404
logpath  = /remotelogs/nginx/access.log
maxretry = 3
findtime = 10s
bantime  = 1h
action   = %(action_)s
           slack

config/filter.d/nginx-404.conf

前回と同じです

config/action.d/slack.conf

各種アクション時に通知するようにします
webhook_url は変更してください

# Fail2Ban configuration file
#
# Action to send notifications to Slack
#

[Definition]

# Option: actionstart
# Notes.: command executed once at the start of Fail2Ban.
actionstart = curl -X POST -H 'Content-type: application/json' \
              --data '{"text":"[Fail2Ban] <name> jail has started"}' \
              <slack_webhook_url>

# Option: actionstop
# Notes.: command executed once at the end of Fail2Ban
actionstop = curl -X POST -H 'Content-type: application/json' \
             --data '{"text":"[Fail2Ban] <name> jail has stopped"}' \
             <slack_webhook_url>

# Option: actioncheck
# Notes.: command executed once before each actionban command
actioncheck =

# Option: actionban
# Notes.: command executed when banning an IP. Take care that the
#         command is executed with Fail2Ban user rights.
actionban = curl -X POST -H 'Content-type: application/json' \
            --data '{"text":"[Fail2Ban] :no_entry: <name> jail banned IP: *<ip>*\nFailures: <failures>\nTime: <time>"}' \
            <slack_webhook_url>

# Option: actionunban
# Notes.: command executed when unbanning an IP. Take care that the
#         command is executed with Fail2Ban user rights.
actionunban = curl -X POST -H 'Content-type: application/json' \
              --data '{"text":"[Fail2Ban] :white_check_mark: <name> jail unbanned IP: *<ip>*"}' \
              <slack_webhook_url>

[Init]

# Slack webhook URL
slack_webhook_url = https://hooks.slack.com/services/xxx/xxx/xxx

動作確認

  • docker compose up -d

あとは localhost/test などで 404 を発生させると通知が来ます
unbanip で ban 解除しても通知が来ます

トラブルシューティング

起動時にちゃんと追加したアクションが読み込まれていることを確認しましょう
ここで読み込まれていないとうまく動作しません

  • docker compose logs | grep ‘action’
fail2ban  |  2025-12-12 10:00:26,132 79986F9C2B28 INFO  Loading configs for action.d/iptables-multiport under /etc/fail2ban
fail2ban  |  2025-12-12 10:00:26,133 79986F9C2B28 DEBUG Reading configs for action.d/iptables-multiport under /etc/fail2ban
fail2ban  |  2025-12-12 10:00:26,133 79986F9C2B28 DEBUG Reading config files: /etc/fail2ban/action.d/iptables-multiport.conf
fail2ban  |  2025-12-12 10:00:26,133 79986F9C2B28 INFO    Loading files: ['/etc/fail2ban/action.d/iptables-multiport.conf']
fail2ban  |  2025-12-12 10:00:26,133 79986F9C2B28 INFO    Loading files: ['/etc/fail2ban/action.d/iptables.conf']
fail2ban  |  2025-12-12 10:00:26,134 79986F9C2B28 INFO    Loading files: ['/etc/fail2ban/action.d/iptables.conf', '/etc/fail2ban/action.d/iptables-multiport.conf']
fail2ban  |  2025-12-12 10:00:26,147 79986F9C2B28 INFO  Loading configs for action.d/slack under /etc/fail2ban
fail2ban  |  2025-12-12 10:00:26,147 79986F9C2B28 DEBUG Reading configs for action.d/slack under /etc/fail2ban
fail2ban  |  2025-12-12 10:00:26,147 79986F9C2B28 DEBUG Reading config files: /etc/fail2ban/action.d/slack.conf
fail2ban  |  2025-12-12 10:00:26,147 79986F9C2B28 INFO    Loading files: ['/etc/fail2ban/action.d/slack.conf']
fail2ban  |  2025-12-12 10:00:26,147 79986F9C2B28 INFO    Loading files: ['/etc/fail2ban/action.d/slack.conf']

最後に

ban になったかどうかをいちいち確認する必要がなくなるので便利です
現在の ban 状況を定期的に送信してくれる機能があると更に便利かなと思います

2025年12月14日日曜日

fail2ban を docker で動かす

fail2ban を docker で動かす

概要

fail2ban をコンテナで動作させる方法を紹介します
よく紹介されているのはホストに直接インストールする方法かなと思います
今回は nginx の不正アクセスを ban する方法を紹介します

環境

  • Ubuntu 24.04
  • docker
  • linuxserver/fail2ban 1.1.0-r2-ls26
  • fail2ban 1.1.0

compose.yaml

fail2ban は linuxserver/fail2ban を使います
fail2ban は仕組み上 iptables を使うのでホストネットワークを使う必要があります

services:
  nginx:
    image: nginx:latest
    container_name: nginx
    network_mode: host
    volumes:
      - ./nginx/log:/var/log/nginx  # このログをfail2banで監視
    restart: unless-stopped

  fail2ban:
    image: linuxserver/fail2ban:latest
    container_name: fail2ban
    network_mode: host
    cap_add:
      - NET_ADMIN # BANに必須
      - NET_RAW   # BANに必須
    volumes:
      - ./config/jail.local:/config/fail2ban/jail.d/jail.local
      - ./config/filter.d/nginx-404.conf:/config/fail2ban/filter.d/nginx-404.conf
      - ./nginx/log:/remotelogs/nginx:ro  # nginxログを読み取り専用で監視
    environment:
      - TZ=Asia/Tokyo
    restart: unless-stopped

./config/jail.local

[DEFAULT]

# "bantime.increment" allows to use database for searching of previously banned ip's to increase a
# default ban time
bantime.increment = true

# "bantime.maxtime" is the max number of seconds using the ban time can reach (doesn't grow further)
bantime.maxtime = 5w

# "bantime.factor" is a coefficient to calculate exponent growing of the formula or common multiplier
bantime.factor = 24

# "bantime" is the number of seconds that a host is banned.
bantime = 1h

# A host is banned if it has generated "maxretry" during the last "findtime"
# seconds.
findtime = 24h

# "maxretry" is the number of failures before a host get banned.
maxretry = 5

# Prevents banning LAN subnets
ignoreip    = 127.0.0.1/8 ::1
              10.0.0.0/8
              172.16.0.0/12
              192.168.0.0/16

# The ban action "iptables-multiport" (default) should work for most
# The ban action "iptables-allports" can be used if multiport causes issues
banaction = iptables-multiport
banaction_allports = iptables-allports

# Read https://github.com/sebres/PoC/blob/master/FW.IDS-DROP-vs-REJECT/README.md before changing block type
# The block type "REJECT --reject-with icmp-port-unreachable" (default behavior) should respond to, but then instantly reject connection attempts
# The block type "DROP" should not respond to connection attempts, resulting in a timeout
#banaction = iptables-multiport[blocktype=DROP]

# Add additional actions
action  = %(action_)s
          apprise-api[host="127.0.0.1", tag="fail2ban"]
          cloudflare[cfuser="YOUR-EMAIL", cftoken="YOUR-TOKEN"]

# [sshd]
# configuration inherits from jail.conf
# enabled = true
# chain   = INPUT
# action  = %(action_)s

[nginx-http-auth]
# configuration inherits from jail.conf
enabled = true
chain   = DOCKER-USER
action  = %(action_)s

[nginx-badbots]
# configuration inherits from jail.d/nginx-badbots.conf
enabled = true
chain   = DOCKER-USER
action  = %(action_)s

[nginx-botsearch]
# configuration inherits from jail.conf
enabled = true
chain   = DOCKER-USER
action  = %(action_)s

[nginx-deny]
# configuration inherits from jail.d/nginx-deny.conf
enabled = true
chain   = DOCKER-USER
action  = %(action_)s

[nginx-unauthorized]
# configuration inherits from jail.d/nginx-unauthorized.conf
enabled = true
chain   = DOCKER-USER
action  = %(action_)s

[nginx-404]
# Custom filter to detect excessive 404 errors
enabled  = true
chain    = INPUT
port     = http,https
filter   = nginx-404
logpath  = /remotelogs/nginx/access.log
maxretry = 3
findtime = 10s
bantime  = 1h

banaction などは適切なものを設定しましょう

ポイントは一番下の nginx-404 です
これで 404 を連発する IP を ban にできます
それ以外も nginx の ban ルールですが認証エラーなどで発生させるのが難しいので今回 404 を追加しています

config/filter.d/nginx-404.conf

# Fail2Ban filter to detect excessive 404 errors from nginx
# Detects clients making too many requests to non-existent pages

[Definition]

failregex = ^<HOST> -.*"(GET|POST|HEAD).*HTTP.*" 404

ignoreregex =

datepattern = {^LN-BEG}%%d/%%b/%%ExY:%%H:%%M:%%S

nginx のログで 404 を正規表現でマッチさせます

起動

  • docker compsoe up -d

動作確認

今回は10秒間に3回404発生でbanなのですぐにbanになります
localhost/test など存在しないページにアクセスしましょう

そして ban になっているか確認します

  • docker compose exec fail2ban fail2ban-client status nginx-404
Status for the jail: nginx-404
|- Filter
|  |- Currently failed: 0
|  |- Total failed:     6
|  `- File list:        /remotelogs/nginx/access.log
`- Actions
   |- Currently banned: 1
   |- Total banned:     1
   `- Banned IP list:   xxx.xxx.xxx.xxx

ban されると i-Filter のお馴染みの画面が表示されるようになります
また iptables -L でホスト側を確認するとちゃんと REJECT ルールがあることが確認できると思います

sudo iptables -L f2b-nginx-404

Chain f2b-nginx-404 (1 references)
target     prot opt source               destination
REJECT     all  --  xxx.xxx.xxx.xxx      anywhere             reject-with icmp-port-unreachable
RETURN     all  --  anywhere             anywhere

ban解除

  • docker compose exec fail2ban fail2ban-client set nginx-404 unbanip xxx.xxx.xxx.xxx

テストなどですぐに解除したい場合は IP を指定して ban 解除できます
iptables にもないことが確認できます

最後に

今回使った linuxserver/fail2ban は /config/fail2ban/filter.d に大量のプリセットがあるのでログをセットするだけでも簡単に ban 監視を開始することができます
今回は 404 ルールだけなかったので手動で追加しています

fail2ban は iptables を操作するツールなので iptables を使ってアクセス制御しているケースとは親和性は高い気がします
逆にクラウドなどのファイアウォールでアクセス制御している場合は fail2ban とは少し相性が悪いので使い分けが必要かなと思います

結局 iptables なのでホストにインストールしても変わりませんが docker compose でアプリを管理していたりホストにはなるべくアプリをインストールしたくないという場合にはやはり docker で fail2ban を動かしたくなるかなと思います

参考サイト

2025年12月11日木曜日

Mac の UTM でディレクトリ共有する方法

Mac の UTM でディレクトリ共有する方法

概要

紹介します

環境

  • macOS 15.7.1
  • UTM 4.7.4
  • Ubuntu 24.04

共有設定

マウント

sudo mkdir -p /mnt/share
sudo mount -t 9p -o trans=virtio share /mnt/share

最後に

特にツールのインストールは不要でした
qemu-guest-agent も不要っぽいです

参考サイト

2025年11月22日土曜日

Speckit 超入門

Speckit 超入門

概要

code-server + speckit を試してみました
一応アプリは作成してくれましたが生成されるファイルが微妙に違うのでまだサポートしていないのかもしれません

環境

  • Ubuntu 24.04
  • speckit (specify 0.0.22)
  • code-server v4.105.1

インストール

  • uv tool install specify-cli --from git+https://github.com/github/spec-kit.git

初期化

  • specify init speckit_test
    • copilot を選択
    • sh を選択

code-server を開く

  • speckit_test を vscode で開く
  • モデルを Claude Sonnet 4.5 にする

以下 code-server の Github copilot chat のチャット欄で作業します

規則作成

  • /speckit.constitution コード品質、テスト標準、ユーザーエクスペリエンスの一貫性、パフォーマンス要件に焦点を当てた原則を作成します。

/home/devops/work/speckit_test/.github/prompts/speckit.constitution.prompt.md が作成された

仕様作成

  • /speckit.specify 家庭や業務用キッチンで使用できるシンプルで視認性の高いタイマーを、Web ブラウザー経由で提供します。1分、3分、5分を設定するためのボタンを配置します。ボタンを押すと、その時間からカウントダウンが開始されます。カウントダウン中は、残り時間を目立つように表示します。カウントダウン中に再度ボタンを押すと、タイマーがリセットされ、新たなカウントダウンが開始されます。

/home/devops/work/speckit_test/.github/prompts/speckit.specify.prompt.md が作成されました

実装計画作成

  • /speckit.plan HTML5、JavaScript(ES6)、CSS3 で作成してください

/home/devops/work/speckit_test/.github/prompts/speckit.plan.prompt.md が作成されました

作業タスクの作成

  • /speckit.tasks

/home/devops/work/speckit_test/.github/prompts/speckit.tasks.prompt.md が作成されました

実装

  • /speckit.implement

/home/devops/work/speckit_test/.github/prompts/speckit.implement.prompt.md が作成されました

また実際に作成されたコードは以下の通りです

ls -ltrR kitchen-timer/
kitchen-timer/:
total 24
drwxr-xr-x 3 devops docker 4096 Nov 21 13:23 assets
-rw-r--r-- 1 devops docker 1844 Nov 21 13:24 index.html
drwxr-xr-x 2 devops docker 4096 Nov 21 13:24 css
drwxr-xr-x 2 devops docker 4096 Nov 21 13:26 js
-rw-r--r-- 1 devops docker 7522 Nov 21 13:26 README.md

kitchen-timer/assets:
total 4
drwxr-xr-x 2 devops docker 4096 Nov 21 13:23 sounds

kitchen-timer/assets/sounds:
total 0

kitchen-timer/css:
total 8
-rw-r--r-- 1 devops docker 6334 Nov 21 13:24 styles.css

kitchen-timer/js:
total 16
-rw-r--r-- 1 devops docker 2975 Nov 21 13:25 timer.js
-rw-r--r-- 1 devops docker 3650 Nov 21 13:25 audio.js
-rw-r--r-- 1 devops docker 6150 Nov 21 13:26 app.js

動作確認

  • cd speckit_test/kitchen-timer
  • python -m http.server 8000
  • curl localhost:8000

最後に

code-server で speckit を動かしてみました
冒頭にも紹介しましたが挙動が微妙でまだ code-server ではサポートしていないのかもしれません

本当は git コマンドで branch も作成してくれるよういなのですがやってくれませんでした

またモデルが GPT-4.1 だと動きませんでした

続けて修正、エンハンスなどしたい場合は /speckit.specify から再度行います

参考サイト

2025年11月11日火曜日

Ubuntu に uv をインストールする方法

Ubuntu に uv をインストールする方法

概要

グローバルな環境にインストールする方法を紹介します
基本は mcp などに使う場合にこの方法でインストールします

環境

  • Ubuntu 24.04
  • uv 0.9.8

コマンド

curl -LsSf https://astral.sh/uv/install.sh | sh

ログ

downloading uv 0.9.8 x86_64-unknown-linux-gnu
no checksums to verify
installing to /home/devops/.local/bin
  uv
  uvx
everything's installed!

インストールされるパス

ホームディレクトリの .local/bin 配下なので注意してください
PATH が設定されていない場合は PATH に追加しましょう

アップグレードする方法

再度インストールするための curl を叩けば OK です

最後に

pip を使ってインストールする場合はパスや管理方法が変わるので注意しましょう

参考サイト

2025年10月22日水曜日

journal ログをすべて削除する方法

journal ログをすべて削除する方法

概要

忘れるのでメモ

環境

  • Ubuntu 22.04

全削除

前

sudo du -sh /var/log/
3.3G    /var/log/
  • sudo journalctl --vacuum-time=1s

削除ログ

Vacuuming done, freed 0B of archived journals from /run/log/journal.
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/user-1002@cb5cf46ac4024d6ab8ac0f7039ee62f0-000000000279f7c3-00063ffa5ec9cd0c.journal (8.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-00000000027b400b-00064004588b93b5.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-00000000027d6843-000640152308d284.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-00000000027f9176-00064025f94a8e93.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-000000000281b863-00064036e00660b8.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-000000000283e0cf-00064047f2873c97.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-00000000028609f5-00064058f8e381d0.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-00000000028834bc-0006406a1746446c.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-00000000028a5e91-0006407b42809cd3.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-00000000028c873b-0006408c87b6d808.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/user-1002@cb5cf46ac4024d6ab8ac0f7039ee62f0-00000000028e2463-0006409965aaafa8.journal (8.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-00000000028eb3bd-0006409dca5e037c.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-000000000290dc16-000640ae8e9c7381.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/user-1002@cb5cf46ac4024d6ab8ac0f7039ee62f0-0000000002912098-000640b0a2d36d3b.journal (8.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-0000000002930478-000640bf5eb5c522.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/user-1002@cb5cf46ac4024d6ab8ac0f7039ee62f0-0000000002936af1-000640c27aa7db32.journal (8.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-0000000002952cde-000640d027fee751.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-000000000297559b-000640e0f3a72cf5.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-0000000002997e37-000640f1d327fe5d.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-00000000029ba58e-00064102c1378bd0.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-00000000029dce0e-00064113bde6de0a.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-00000000029ff7c5-00064124cc9e6f43.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-0000000002a2215b-00064135ea1f4111.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-0000000002a44b4b-000641471cc25b72.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-0000000002a6736b-00064158657fee95.journal (128.0M).
Deleted archived journal /var/log/journal/95b2c59cdf7701096ea7d3386e92e124/system@6e6c307cc5634e74888ce601b9437fcf-0000000002a89d70-00064169c011da77.journal (128.0M).
Vacuuming done, freed 2.7G of archived journals from /var/log/journal/95b2c59cdf7701096ea7d3386e92e124.
Vacuuming done, freed 0B of archived journals from /var/log/journal.

後

sudo du -sh /var/log/
443M    /var/log/

微妙に残ります
インスタンス自体を再起動すると更に減ります

du 以外にも journalctl 専用のコマンドでログの使用量を確認することもできます

  • sudo journalctl --disk-usage
Archived and active journals take up 136.0M in the file system.

そもそも保存させる容量を調整する

  • sudo vim /etc/systemd/journald.conf
[Journal]
SystemMaxUse=100M
  • sudo systemctl restart systemd-journald

ちなみに SystemMaxUse のデフォルトはディスクサイズの10%なので30GBのディスクであれば3.0GBほど保存します

最後に

だいたい dockerd のログでうまります

参考サイト

2025年9月8日月曜日

pyenv 自身を更新する方法

pyenv 自身を更新する方法

概要

Homebrew などは brew update すればいいですが Ubuntu などに直接インストールした場合にはそうはいきません
今回はそんな場合の pyenv のバージョンアップ方法を紹介します

環境

  • Ubuntu 24.04
  • pyenv 2.6.1 -> 2.6.7

コマンド

  • pyenv update

最後に

一定以上の pyenv であればデフォルトで update コマンドが使えます
古い pyenv であれば

  • rm -rf ~/.pyenv
  • curl https://pyenv.run | bash

で最新バージョンをインストールし直すといいかなと思います
ただこの方法だとインストールした Python までアンインストールされるのでインストールコマンドだけ実行しても最新版になるかもしれません

参考サイト

2025年8月31日日曜日

code-server に Github copilot chat プラグインをインストールする方法

code-server に Github copilot chat プラグインをインストールする方法

概要

code-server の最新版に Github 公式の copilot-chat のプラグインがインストールできたのでインストール方法を紹介します

ポイントは code-server 自体で一度 Github アカウントにログインする必要がある点です

環境

  • Ubuntu 24.04
  • code-server v4.103.2
  • Github.copilot-chat 0.30.3
    • 執筆時点の最新バージョン 0.32 系はインストールできないのでご注意ください

code-server で Github へのログイン

  • Ctrl + p (コマンドパレットに移動)
  • > Publish to Github と入力
  • すると Github にアカウントするためのトークンが表示されるので https://github.com/login/device にアクセスし code-server が発行してくれたトークンを入力
  • code-server に戻り左メニュー下のアカウントアイコンをクリックしログインできていること確認

Github.copilot-chat のインストール

code-server のマーケットプレイスでは公開されていないので vsix ファイルを直接ダウンロードしインストールします

  • VERSION="0.30.3"
  • curl -o "copilot-chat-${VERSION}.vsix" --compressed "https://marketplace.visualstudio.com/_apis/public/gallery/publishers/GitHub/vsextensions/copilot-chat/${VERSION}/vspackage"
  • code-server --install-extension "copilot-chat-${VERSION}.vsix"

リリースされているバージョンの一覧は Github のタグを見るのが簡単です
https://github.com/microsoft/vscode-copilot-chat/tags

注意事項

  • 最新版はそのうちインストールできるようになると思います
  • 最新版への更新はマーケットプレイスを経由していないため code-server からは行えないので手動で行う必要があります、方法はインストール時と同じです
  • 古いバージョンはプラグイン自体にログインボタンがあるがその方法は廃止されログインできても使えないので注意 (0.27 など)

最後に

直接ファイルをダウンロードしてインストールする形式なので面倒ですが一応これで動作しました

非公式の copilot-chat プラグインもあるようなのですがアカウントが必要だったりプラグインからのログインがうまくできなかったりするので無理やりでも非公式の古いバージョンを使うほうがいいのかもしれません

参考サイト

2025年8月29日金曜日

code-server は https 化しないと拡張機能が使えない

code-server は https 化しないと拡張機能が使えない

概要

RooCode などほとんどの拡張機能のページは https 化されていることが前提です
今回は code-server を https 化する方法を紹介します

環境

  • Ubuntu 24.04
  • code-server v4.103.2

A レコードの登録

名前でアクセスできる必要があるので code-server が動作しているサーバの IP の A レコードを登録します

証明書の取得

何でも OK です
certbot などを使って取得します

取得した鍵と証明書は適当なパスに配置しておきましょう

code-server の設定変更

  • vim /usr/lib/systemd/system/code-server@.service
[Unit]
Description=code-server
After=network.target

[Service]
Type=exec
# ExecStart=/usr/bin/code-server
ExecStart=/usr/bin/code-server --cert /home/hawk/certs/my_code_server.crt --cert-key /home/hawk/certs/my_code_server.key
Restart=always
User=%i

[Install]
WantedBy=default.target

/home/hawk/certs/my_code_server.crt と /home/hawk/certs/my_code_server.key は先程取得した証明書と鍵へのパスになります

動作確認

  • sudo systemctl daemon-reload && sudo systemctl restart code-server@devops

これで https でアクセスできることを確認しましょう

最後に

証明書は自己証明書を使う方法がネットでよく紹介されていますが最近だと簡単に取得できます
ただドメインがそもそも必要なのでドメインがない場合には自己証明書を使う方法になるかなと思います

参考サイト

2025年8月19日火曜日

Ubuntu に code-server (vscode) をインストールする方法

Ubuntu に code-server (vscode) をインストールする方法

概要

code-server はブラウザ版 vscode になります
Ubuntu24.04 にインストールしたのでコマンドをメモしておきます

環境

  • Ubuntu 24.04
  • code-server 4.102.3

インストール

  • curl -fsSL https://code-server.dev/install.sh | sh

systemctl 有効化

  • sudo systemctl enable --now code-server@$USER

起動確認

  • sudo systemctl status code-server@$USER

起動ポート変更

  • vim /home/devops/.config/code-server/config.yaml
bind-addr: 0.0.0.0:8081
  • sudo systemctl restart code-server@$USEr

動作確認

IP:8081 でアクセスして vscode が表示されることを確認しましょう

最後に

code-server でも mcp は使えるのだろうか

参考サイト

2025年7月14日月曜日

Ubuntuで仮想NICを作成しIPを設定する方法

Ubuntuで仮想NICを作成しIPを設定する方法

概要

systemd に登録しないと毎回仮想NICを作成することになるので systemd を使うのが簡単です

環境

  • Ubuntu 24.04

dummy0.service ファイルの作成

  • sudo vim /etc/systemd/system/dummy0.service
Unit]
Description=Setup dummy0 interface
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/sbin/modprobe dummy
ExecStart=/sbin/ip link add dummy0 type dummy
ExecStart=/sbin/ip link set dummy0 up
ExecStart=/sbin/ip addr add 192.168.1.100/16 dev dummy0
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

sudo systemctl enable dummy0.service

dummy というモジュールを使うので最初に modprobe で読み込みます
あとは dummy0 という名前の仮想デバイスを作成しそこに IP を追加します

動作確認

再起動して仮想NICが作成されていることを確認しましょう

  • ip -br a show dummy0
dummy0           UNKNOWN        192.168.1.100/16 fe80::58e6:72ff:fe62:cd5f/64

最後に

dummy インタフェースなのでアクセスできるのはマシンのみからとなります
外部からアクセスしたい場合にはNICに複数のIPを持たせる必要があります

2025年7月8日火曜日

unattended-upgrade に docker の公式リポジトリを追加する方法

unattended-upgrade に docker の公式リポジトリを追加する方法

概要

過去に ESM パッケージを更新する定義を追加しました
今回は docker 公式と terraform/ansible も追加してみたのでその手順を紹介します

環境

  • Ubuntu 24.04
  • unattended-upgrade 2.9.1

docker

  • grep -e 'Origin:' -e 'Suite:' /var/lib/apt/lists/download.docker.com_linux_ubuntu_dists_noble_*
/var/lib/apt/lists/download.docker.com_linux_ubuntu_dists_noble_InRelease:Origin: Docker
/var/lib/apt/lists/download.docker.com_linux_ubuntu_dists_noble_InRelease:Suite: noble
  • sudo vim /etc/apt/apt.conf.d/52unattended-upgrades-docker-packages
Unattended-Upgrade::Allowed-Origins {
        "Docker:noble";
};
  • sudo unattended-upgrade --dry-run
/usr/bin/dpkg --status-fd 10 --no-triggers --unpack --auto-deconfigure /var/cache/apt/archives/docker-ce-cli_5%3a28.3.1-1~ubuntu.24.04~noble_amd64.deb /var/cache/apt/archives/docker-ce_5%3a28.3.1-1~ubuntu.24.04~noble_amd64.deb /var/cache/apt/archives/docker-ce-rootless-extras_5%3a28.3.1-1~ubuntu.24.04~noble_amd64.deb /var/cache/apt/archives/docker-compose-plugin_2.38.1-1~ubuntu.24.04~noble_amd64.deb
/usr/bin/dpkg --status-fd 10 --configure --pending
/usr/bin/dpkg --status-fd 10 --no-triggers --unpack --auto-deconfigure /var/cache/apt/archives/docker-buildx-plugin_0.25.0-1~ubuntu.24.04~noble_amd64.deb
/usr/bin/dpkg --status-fd 10 --configure --pending

terraform

  • grep -e 'Origin:' -e 'Suite:' /var/lib/apt/lists/apt.releases.hashicorp.com_dists_noble_*
/var/lib/apt/lists/apt.releases.hashicorp.com_dists_noble_InRelease:Origin: Artifactory
/var/lib/apt/lists/apt.releases.hashicorp.com_dists_noble_InRelease:Suite: noble
  • sudo vim /etc/apt/apt.conf.d/53unattended-upgrades-hashicorp-packages
Unattended-Upgrade::Allowed-Origins {
        "Artifactory:noble";
};
  • sudo unattended-upgrade --dry-run
/usr/bin/dpkg --status-fd 10 --no-triggers --unpack --auto-deconfigure /var/cache/apt/archives/terraform_1.12.2-1_amd64.deb
/usr/bin/dpkg --status-fd 10 --configure --pending

ansible

  • grep -e 'Origin:' -e 'Suite:' /var/lib/apt/lists/ppa.launchpadcontent.net_ansible_ansible_ubuntu_dists_noble_*
/var/lib/apt/lists/ppa.launchpadcontent.net_ansible_ansible_ubuntu_dists_noble_InRelease:Origin: LP-PPA-ansible-ansible
/var/lib/apt/lists/ppa.launchpadcontent.net_ansible_ansible_ubuntu_dists_noble_InRelease:Suite: noble
  • sudo vim /etc/apt/apt.conf.d/54unattended-upgrades-ansible-packages
Unattended-Upgrade::Allowed-Origins {
        "LP-PPA-ansible-ansible:noble";
};
  • sudo unattended-upgrade --dry-run
/usr/bin/dpkg --status-fd 10 --no-triggers --unpack --auto-deconfigure /var/cache/apt/archives/ansible_11.7.0-1ppa~noble_all.deb
/usr/bin/dpkg --status-fd 10 --configure --pending

最後に

他のリポジトリも全部同じ方法で unattended-upgrade に追加できます
この作業をリポジトリを追加したときに自動でやってくれるツールはないのだろうか

2025年5月15日木曜日

Ubuntu24.04にChromeの最新版をインストールする方法

Ubuntu24.04にChromeの最新版をインストールする方法

概要

apt でインストールできます

環境

  • Ubuntu24.04
  • Chrome 136.0.7103.92-1

gpgキー取得

  • wget -qO- https://dl.google.com/linux/linux_signing_key.pub | sudo gpg --yes --dearmor -o /etc/apt/trusted.gpg.d/google-chrome.gpg

リポジトリ追加

  • sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'

インストール

  • sudo apt -y update
  • sudo apt install -y google-chrome-stable

最後に

headless でも使えるのでインストールしておくと便利かもです

参考サイト