1806 Words 8 min

はじめに

自宅のラボ環境に外部からアクセスするにあたって MFA 等を利用したセキュアな踏み台サーバを構築したいと考え、 OSS の Teleport Community Edition を利用しました。
サーバ OS は Rocky Linux 9.6 を利用し、最小限のインストール/標準 でセットアップされた状態から Teleport Community Edition をインストールしていますのでこの記事ではインストール手順を解説します。
私と同じ様にできるだけお金をかけずに自宅ラボ環境をセキュアに外部からアクセスしたいと検討されている方の参考になれば幸いです。
 

本記事は以下の前提で記載しております。

  • 事前にサーバのネットワーク設定、外部からアクセスするためにホームルーターのポートマッピング、ファイアウォール設定が完了した状態
  • 外部公開用のドメインは MyDNS で新規ドメイン (example.mydns.jp) を取得した状態 (ドメイン名はあくまで仮定)
  • 外部公開用のドメインはサーバの IP アドレスに名前解決 (A レコード登録) できる状態

 

この記事を読んで欲しい人

  • セキュアな踏み台サーバを利用したいと考えている人
  • できるだけお金をかけずに自宅ラボ環境をセキュアに外部からアクセスしたいと検討されている人

 

Teleport インストール手順

本記事では、ドメイン名として example.mydns.jp を使用しています。
コマンドを実行する際は、ご自身が取得されたドメイン名に置き換えて実行してください。

本記事はあくまで初期インストールの手順の解説を目的としているため、実際に外部公開される場合には十分なセキュリティ対策を講じるようにしてください。

 

Let’s Encrypt (Certbot) によるSSL証明書取得

  1. EPELリポジトリの有効化、certbotインストール

    dnf install epel-release -y
    
    ...
    インストール済み:
      epel-release-9-10.el9.noarch
    
    完了しました!
    

     

    dnf install certbot -y
    
    ...
    インストール済み:
      certbot-3.1.0-1.el9.noarch                fontawesome-fonts-1:4.7.0-13.el9.noarch         python-josepy-doc-1.14.0-1.el9.noarch       python3-acme-3.1.0-1.el9.noarch                  python3-certbot-3.1.0-1.el9.noarch
      python3-cffi-1.14.5-5.el9.x86_64          python3-configargparse-1.7.5-1.el9.noarch       python3-configobj-5.0.6-25.el9.noarch       python3-cryptography-36.0.1-5.el9_6.x86_64       python3-importlib-metadata-4.12.0-2.el9.noarch
      python3-josepy-1.14.0-1.el9.noarch        python3-parsedatetime-2.6-5.el9.noarch          python3-ply-3.11-14.el9.0.1.noarch          python3-pyOpenSSL-21.0.0-1.el9.noarch            python3-pycparser-2.20-6.el9.noarch
      python3-pyrfc3339-1.1-11.el9.noarch       python3-pytz-2021.1-5.el9.noarch                python3-zipp-3.20.1-2.el9.noarch
    
    完了しました!
    

     

  2. ファイアウォール設定 (HTTP/HTTPS通信許可)
    Teleport は HTTPS (Port 443) を利用します。
    今回は Let’s Encrypt (Certbot) によるSSL証明書取得にスタンドアロンモードを利用するため、 HTTP (Port 80) についても通信許可を設定しています。

    firewall-cmd --add-service=http --zone=public --permanent
    firewall-cmd --add-service=https --zone=public --permanent
    
    success
    

     

    ファイアウォールルールの即時反映

    firewall-cmd --reload
    

     

  3. Let’s Encrypt (Certbot) によるSSL証明書取得
    --standalone は、Certbot自体が一時的なWebサーバ (Port 80) を立ち上げてドメイン認証を行う方式です。
    Nginx や Apache などの Web サーバがまだ動いていない、まっさらな環境でドメイン認証を行うのに最適な方法かと思います。

    certbot certonly --standalone \
      -d example.mydns.jp \
      -n \
      --agree-tos \
      --email=admin@example.mydns.jp
    
    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    Account registered.
    Requesting a certificate for example.mydns.jp
    
    Successfully received certificate.
    Certificate is saved at: /etc/letsencrypt/live/example.mydns.jp/fullchain.pem
    Key is saved at:         /etc/letsencrypt/live/example.mydns.jp/privkey.pem
    This certificate expires on 2026-mm-dd.
    These files will be updated when the certificate renews.
    Certbot has set up a scheduled task to automatically renew this certificate in the background.
    
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    If you like Certbot, please consider supporting our work by:
    * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
    * Donating to EFF:                    https://eff.org/donate-le
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    

     

  4. Let’s Encrypt (Certbot) によって生成した証明書と秘密鍵の確認

    ls -l /etc/letsencrypt/live/example.mydns.jp/
    
    合計 4
    -rw-r--r--. 1 root root 692  5月 17 16:10 README
    lrwxrwxrwx. 1 root root  36  5月 17 16:10 cert.pem -> ../../archive/example.mydns.jp/cert1.pem
    lrwxrwxrwx. 1 root root  37  5月 17 16:10 chain.pem -> ../../archive/example.mydns.jp/chain1.pem
    lrwxrwxrwx. 1 root root  41  5月 17 16:10 fullchain.pem -> ../../archive/example.mydns.jp/fullchain1.pem
    lrwxrwxrwx. 1 root root  39  5月 17 16:10 privkey.pem -> ../../archive/example.mydns.jp/privkey1.pem
    

     

Teleport インストール

  1. Teleport インストールのためのエラー回避策 Rocky Linux では普通に公式のページで案内されているスクリプトを実行しても以下のエラーが出力され、 Teleport をインストールすることができませんでした。

    Status code: 404 for https://yum.releases.teleport.dev/rocky/9/Teleport/x86_64/stable/v18/teleport-yum.repo (IP: xxx.xxx.xxx.xxx)
    エラー: repo の設定に失敗しました
    

     

    苦肉の策にはなりますが、、、 インストールスクリプトの中で /etc/os-release の ID を基に OS を判定し、インストール処理を行っているため、一時的に RHEL として判定させてインストールしました。

    cp -ip /etc/os-release /etc/os-release.bak
    vi /etc/os-release
    

    3行目の ID を rocky → rhel に修正

    NAME="Rocky Linux"
    VERSION="9.7 (Blue Onyx)"
    ID="rhel"
    

     

    ファイルを上書き保存

    :wq!
    

     

  2. Teleport Community Edition インストール

    curl https://cdn.teleport.dev/install.sh | bash -s "18.8.0" "oss"
    

    エラー回避策を行ったことで正常にインストール処理が走ります。

    ...
    インストール済み:
      teleport-18.8.0-1.x86_64
    
    完了しました!
    
    Teleport v18.8.0 git:v18.8.0-0-g3d1f25fa go1.25.10 installed successfully!
    
    The following commands are now available:
      teleport        - The daemon that runs the Auth Service, Proxy Service, and other Teleport services.
      tsh             - A tool that lets end users interact with Teleport.
      tctl            - An administrative tool that can configure the Teleport Auth Service.
      tbot            - Teleport Machine ID client.
      fdpass-teleport - Teleport Machine ID client.
      teleport-update - Teleport auto-update agent.
    

     

  3. Teleport インストールのためのエラー回避策戻し
    事前にコピーしておいた .bak ファイルを利用して設定を元に戻します。

    cp -ip /etc/os-release.bak /etc/os-release
    
    cp: '/etc/os-release' を上書きしますか? y
    

     

  4. Teleport 設定ファイル生成

    teleport configure -o file \
      --cluster-name=example.mydns.jp \
      --public-addr=example.mydns.jp:443 \
      --cert-file=/etc/letsencrypt/live/example.mydns.jp/fullchain.pem \
      --key-file=/etc/letsencrypt/live/example.mydns.jp/privkey.pem
    
    A Teleport configuration file has been created at "/etc/teleport.yaml".
    To start Teleport with this configuration file, run:
    
    teleport start --config="/etc/teleport.yaml"
    
    Happy Teleporting!
    

     

  5. Teleport サービスの自動起動設定

    systemctl enable teleport.service
    
    Created symlink /etc/systemd/system/multi-user.target.wants/teleport.service → /usr/lib/systemd/system/teleport.service.
    

     

  6. Teleport サービスの再起動と確認

    systemctl restart teleport.service
    systemctl status teleport.service
    
    ● teleport.service - Teleport Service
        Loaded: loaded (/usr/lib/systemd/system/teleport.service; enabled; preset: disabled)
        Active: active (running) since Sun 2026-05-17 16:14:37 JST; 15ms ago
      Main PID: 6429 (teleport)
          Tasks: 5 (limit: 48874)
        Memory: 6.1M (peak: 6.1M)
            CPU: 14ms
        CGroup: /system.slice/teleport.service
                mq6429 /usr/local/bin/teleport start --config /etc/teleport.yaml --pid-file=/run/teleport.pid
    
    5月 17 16:14:37 test-242.lab.internal systemd[1]: Started Teleport Service.
    

     

  7. Teleport アクセス確認
    https://example.mydns.jp (URLのドメイン名はご自身のドメイン名に変更) にアクセスし、 Teleport の画面が表示されることを確認します。

     

環境

  • Rocky Linux 9.6
  • Teleport 18.8.0