0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OCI Cloud Free Tier をもぎ取れ その15

Last updated at Posted at 2025-01-25

概要

OCI Cloud Free Tierを取得してみた。
elixirのlivebookをsystemdでセキュアに立ち上げたいをcopilotに聞いてみた。

質問

elixirのlivebookをsystemdでセキュアに立ち上げたい

回答

Livebooksystemd で安全に実行するための手順を以下に示しますね。

前提条件

  1. Livebookが配置されているディレクトリと同じ場所にlivebookユーザーを作成する。
  2. 以下のコードを使って、Livebookバイナリをダウンロードしてインストール。
    curl -fsSL https://github.com/livebook-dev/livebook/releases/latest/download/livebook.bat -o /usr/local/bin/livebook
    chmod +x /usr/local/bin/livebook
    
  3. systemdユニットファイルの作成。

手順

  1. ユーザー作成

    sudo useradd -r -s /bin/false livebook
    
  2. systemdユニットファイル作成
    新しいユニットファイル/etc/systemd/system/livebook.serviceを作成。

    sudo nano /etc/systemd/system/livebook.service
    

    以下の内容を入力。

    [Unit]
    Description=Livebook server
    After=network.target
    
    [Service]
    User=livebook
    ExecStart=/usr/local/bin/livebook server --bind 0.0.0.0 --port 8080
    Restart=always
    Environment="LIVEBOOK_PASSWORD=your-secure-password"
    # Restricting file system access: 
    ProtectSystem=full
    ProtectHome=true
    PrivateTmp=true
    NoNewPrivileges=true
    
    [Install]
    WantedBy=multi-user.target
    
  3. サービスの有効化と起動
    これでsystemdにサービスを設定します。

    sudo systemctl enable livebook.service
    sudo systemctl start livebook.service
    
  4. ステータス確認

    sudo systemctl status livebook.service
    

セキュア設定
ProtectSystem=fullPrivateTmp=trueなどのオプションはシステムの一部を分離し、Livebookのプロセスがファイルシステムに影響を与えるのを防ぎます。

これでLivebookをセキュアに実行できるようになります。質問や追加のヘルプがあれば教えてくださいね!

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?