> For the complete documentation index, see [llms.txt](https://manual.dxable.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://manual.dxable.com/1password/use-1password-cli-with-a-connect-server.md).

# Connectサーバーで1Password CLIを使用する

1Password CLI を[Connect サーバー](https://developer.1password.com/docs/connect/)と共に使用して、コマンド ラインでシークレットをプロビジョニングし、アイテムを取得できます。

### 必要条件 <a href="#bvq2jmfou29x" id="bvq2jmfou29x"></a>

Connect サーバーで 1Password CLI を使う前に、次の操Createを行う必要があります。

* 1Passwordに[サインアップします](https://start.1password.com/sign-up/plan)。
* [1Password Connect をデプロイします](https://developer.1password.com/docs/connect/get-started/#step-2-deploy-1password-connect-server)。
* Connect サーバーを本番環境からアクセスできるようにします。
* [1Password CLI を本番環境にインストールします。](https://developer.1password.com/docs/cli/install-server/)
* OP\_CONNECT\_HOSTおよびOP\_CONNECT\_TOKEN環境変数を、運用環境の Connect インスタンスの資格情報に設定します。

### [**始めましょう**](https://developer.1password.com/docs/connect/connect-cli/#get-started) <a href="#uw8onjlxpu81" id="uw8onjlxpu81"></a>

必要な手順を完了すると、Connect サーバーで次の 1Password CLI コマンドを使用できるようになります。

* [op run](https://developer.1password.com/docs/cli/reference/commands/run/)
* [op inject](https://developer.1password.com/docs/cli/reference/commands/inject/)
* [op read](https://developer.1password.com/docs/cli/reference/commands/read/)
* [op item get --format json](https://developer.1password.com/docs/cli/reference/management-commands/item/#item-get)

詳細については、コマンドのドキュメントを参照してください。

### **継続的インテグレーション（CI）環境** <a href="#o7w4k3o3ciyg" id="o7w4k3o3ciyg"></a>

継続的インテグレーション (CI) パイプラインで Connect サーバーと共に 1Password CLI を使うこともできます。1Password CLI を使うと、コード内でプレーンテキスト シークレットの代わりに[シークレット参照](https://developer.1password.com/docs/cli/secret-references/)を使用できます。CI 環境を構成して、環境ごとに異なるシークレット セットを渡すこともできます。

シークレット参照は、他の構成と一緒に定義できるため、インフラストラクチャ アズ コード ツールおよび CI 構成内で適切に機能します。

#### **GitLab CI の例** <a href="#sqlxhcqepfj2" id="sqlxhcqepfj2"></a>

次のコードブロックは、MySQL サービスを実装する GitLab CI 構成ファイルの例を示しています。GitLabs[.gitlab-ci.ymlドキュメントを参照してください。](https://docs.gitlab.com/ee/ci/yaml/)。

.gitlab-ci.yml

services:

\- mysql

variables:

\# Configure mysql service (<https://hub.docker.com/\\_/mysql/>)

MYSQL\_DATABASE: op\://prod/mysql/database

MYSQL\_USERNAME: op\://prod/mysql/username

MYSQL\_PASSWORD: op\://prod/mysql/password

connect:

image: mysql

script:

\- echo "SELECT 'OK';" | op run -- mysql --user="$MYSQL\_USERNAME" --password="$MYSQL\_PASSWORD" --host=mysql "$MYSQL\_DATABASE"



CI パイプラインで 1Password CLI を認証するには、 CI 構成ファイルにOP\_CONNECT\_HOSTおよびOP\_CONNECT\_TOKEN環境変数を追加します。これらの環境変数が存在すると、1Password CLI は Connect サーバーを使用してシークレットを取得するようになります。

次のコード ブロックは、GitLab CI の例を拡張して Connect 環境変数を含めます。

.gitlab-ci.yml

services:

\- mysql

variables:

\# Configure mysql service (<https://hub.docker.com/\\_/mysql/>)

MYSQL\_DATABASE: op\://prod/mysql/database

MYSQL\_USERNAME: op\://prod/mysql/username

MYSQL\_PASSWORD: op\://prod/mysql/password

\# Configure 1Password CLI to use Connect

OP\_CONNECT\_HOST: \<Connect host URL>:8080

OP\_CONNECT\_TOKEN: token

connect:

image: mysql

script:

\- echo "SELECT 'OK';" | mysql --user="$MYSQL\_USERNAME" --password="$MYSQL\_PASSWORD" --host=mysql "$MYSQL\_DATABASE"



### **さらに詳しく** <a href="#rm3fsqjrh6uc" id="rm3fsqjrh6uc"></a>

#### [**プレーンテキストのシークレットをシークレット**](https://developer.1password.com/docs/cli/secret-references/)[**参照**](https://developer.1password.com/docs/connect/connect-cli/#replace-plaintext-secrets-with-secret-references) <a href="#im3b9fd2fnlx" id="im3b9fd2fnlx"></a>

コード内にプレーンテキストのシークレットを配置することを避けるために、シークレット参照をCreateして使う方法を学習します。

#### [**環境**](https://developer.1password.com/docs/connect/connect-cli/#load-secrets-into-the-environment)[**にシークレットをロードする**](https://developer.1password.com/docs/cli/secrets-environment-variables/) <a href="#sb0g7sxo8hh0" id="sb0g7sxo8hh0"></a>

環境からアプリケーションにシークレットを取得する方法を紹介します。

#### [**シークレットを構成**](https://developer.1password.com/docs/cli/secrets-config-files/)[**ファイル**](https://developer.1password.com/docs/connect/connect-cli/#load-secrets-into-config-files) <a href="#vzsh5gf4n6ul" id="vzsh5gf4n6ul"></a>

コード内にプレーンテキストのシークレットを配置せずに、シークレットを構成ファイルに自動的にロードする方法を紹介します。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://manual.dxable.com/1password/use-1password-cli-with-a-connect-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
