> ## Documentation Index
> Fetch the complete documentation index at: https://www.1password.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Sign in to your 1Password account manually

export const CodeResult = ({children, resultLang, wrap, expandable}) => {
  const parseChildren = () => {
    let language = "text";
    let codeContent = "";
    const extractText = node => {
      if (typeof node === "string") {
        return node;
      }
      if (Array.isArray(node)) {
        return node.map(extractText).join("");
      }
      if (node?.props?.children) {
        return extractText(node.props.children);
      }
      return "";
    };
    const extractLanguage = node => {
      if (!node) return null;
      if (node.props?.className) {
        const className = node.props.className;
        const langMatch = className.match(/language-(\w+)/);
        if (langMatch) {
          return langMatch[1];
        }
      }
      if (node.props?.["data-language"]) {
        return node.props["data-language"];
      }
      if (node.props?.language) {
        return node.props.language;
      }
      return null;
    };
    if (typeof children === "string") {
      codeContent = children;
    } else if (Array.isArray(children)) {
      codeContent = extractText(children);
      for (const child of children) {
        const detectedLang = extractLanguage(child);
        if (detectedLang) {
          language = detectedLang;
          break;
        }
      }
    } else if (children?.props) {
      const detectedLang = extractLanguage(children);
      if (detectedLang) {
        language = detectedLang;
      }
      codeContent = extractText(children);
    }
    const parts = codeContent.split("#code-result");
    if (parts.length < 2) {
      return {
        command: codeContent.trim(),
        result: null,
        language,
        defaultOpen: false
      };
    }
    const resultText = parts[1].trim();
    const defaultOpen = resultText.startsWith("open");
    const cleanResult = defaultOpen ? resultText.slice(4).trim() : resultText;
    return {
      command: parts[0].trim(),
      result: cleanResult,
      language,
      defaultOpen
    };
  };
  const {command, result, language, defaultOpen} = parseChildren();
  const [isOpen, setIsOpen] = useState(defaultOpen);
  if (!result) {
    return children;
  }
  return <div className="codeblock_accordion not-prose mb-4">
      {}
      <div className="[&>*]:!mb-0 [&>*]:!rounded-b-none">
        <CodeBlock language={language} children={command} wrap={wrap} expandable={expandable} />
      </div>

      {}
      <div className="see_results_container border-t-0 bg-gray-100/80 dark:bg-gray-800/80 overflow-hidden" style={{
    marginTop: "-0.25rem"
  }}>
        <button onClick={() => setIsOpen(!isOpen)} className="w-full px-4 py-2.5 flex items-center gap-1 text-left text-[14px] font-medium text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-200/60 dark:hover:bg-gray-700/60 transition-all duration-150" aria-expanded={isOpen}>
          {isOpen ? <Icon icon="caret-down" size="14" iconType="solid" /> : <Icon icon="caret-right" size="14" iconType="solid" />}

          <span>See result...</span>
        </button>

        {isOpen && <div className="[&>*]:!mt-0 [&>*]:!rounded-t-none border-t border-[var(--op-border-ui)] dark:border-[var(--op-border-ui-dark)]">
            <CodeBlock language={resultLang || language} children={result} wrap={wrap} expandable={expandable} />
          </div>}
      </div>
    </div>;
};

If you don't want to [use the 1Password app to sign in to 1Password CLI](/cli/get-started/#step-2-turn-on-the-1password-desktop-app-integration), you can manually add and sign in to your accounts in the terminal.

<Danger>
  **Known security risks**

  If you sign in to 1Password CLI manually, any process running under the current user can, on some platforms, potentially access your 1Password account.

  We recommend you [use the 1Password app to sign in to 1Password CLI](/cli/app-integration/) because it offers more robust security guarantees.
</Danger>

When you sign in manually in the terminal, 1Password CLI stores your session key encrypted on disk and the random wrapper key used in the environment of the current shell.

Sessions expire after 30 minutes of inactivity, after which you’ll need to sign in again and save a new token. If you want to immediately terminate your authenticated session, you can run `op signout`.

## Sign in manually

### Step 1: Add an account

To manually add a 1Password account to 1Password CLI, use [`op account add`](/cli/reference/management-commands/account/):

```shell theme={null}
op account add
```

1Password CLI will prompt you to enter your [sign-in address](https://support.1password.com/sign-in-troubleshooting#if-youre-asked-for-a-sign-in-address), email address, [Secret Key](https://support.1password.com/secret-key/), and 1Password account password.

<Tip>
  For non-interactive shells in local environments, sign in with the [1Password desktop app integration](/cli/app-integration/) instead.

  For non-interactive shells in remote environments, authenticate with a [service account](/service-accounts/) or a [Connect server](/connect/).
</Tip>

#### Set a custom account shorthand

1Password CLI uses account shorthands to refer to each of the accounts you add. The default shorthand is your [sign-in address](https://support.1password.com/sign-in-troubleshooting#if-youre-asked-for-a-sign-in-address) subdomain (for example, `my` for `my.1password.com`).

To set a custom shorthand, include the `--shorthand` flag when you add an account. For example, to add an account with the shorthand `personal`:

```shell theme={null}
op account add --shorthand personal
```

### Step 2: Sign in

If you added your accounts to 1Password CLI manually, you'll need to use the [manual sign-in command](/cli/reference/commands/signin/) to sign in.

This command also works with the [app integration](/cli/app-integration) turned on, so you can use it in scripts to provide compatibility for all users regardless of their sign-in method.

<Tabs groupId="shells">
  <Tab title="Bash, Zsh, sh, fish">
    ```shell theme={null}
    eval "$(op signin)"
    ```
  </Tab>

  <Tab title="PowerShell">
    ```powershell theme={null}
    Invoke-Expression "$(op signin)"
    ```
  </Tab>
</Tabs>

After you sign in, 1Password CLI creates a session token and sets the `OP_SESSION` environment variable to it. Include the `--raw` flag to get a token you can export manually.

Session tokens expire after 30 minutes of inactivity, after which you’ll need to sign in again and save a new token.

To sign out, use the command [`op signout`](/cli/reference/commands/signout/).

### Optional: Switch between accounts with the `--account` flag

If you've added multiple accounts and are using an interactive terminal, 1Password CLI will prompt you to select the account you want to sign in to. Use the arrow keys to select an account, then press the <kbd>Return</kbd> key to sign in.

In most shells, you can bypass the prompt to select an account using the `--account` flag with your [account shorthand, sign-in address, or ID](#appendix-find-an-account-shorthand-or-id). This option isn't available in PowerShell. For example:

<Tabs groupId="shells">
  <Tab title="Bash, Zsh, sh, fish">
    ```shell theme={null}
    eval "$(op signin --account personal)"
    ```
  </Tab>
</Tabs>

To always sign in to the same account, set the `OP_ACCOUNT` environment variable to your [account shorthand, sign-in address, or ID](#appendix-find-an-account-shorthand-or-id).

<Tabs groupId="shells">
  <Tab title="Bash, Zsh, sh">
    ```shell theme={null}
    export OP_ACCOUNT=my.1password.com
    ```
  </Tab>

  <Tab title="fish">
    ```shell theme={null}
    set -x OP_ACCOUNT my.1password.com
    ```
  </Tab>

  <Tab title="PowerShell">
    ```powershell theme={null}
    $Env:OP_ACCOUNT = "my.1password.com"
    ```
  </Tab>
</Tabs>

You can sign in to multiple accounts at the same time, then use the `--account` flag to specify which account should execute each command. If you don't specify an account, 1Password CLI will default to the account you most recently signed in to.

For example, to sign in to accounts with the shorthands `personal` and `agilebits`:

<Tabs groupId="shells">
  <Tab title="Bash, Zsh, sh, fish">
    ```shell theme={null}
    eval "$(op signin --account personal)" && eval "$(op signin --account agilebits)"
    ```
  </Tab>

  <Tab title="PowerShell">
    ```powershell theme={null}
    Invoke-Expression "$(op signin --account personal)"; Invoke-Expression "$(op signin --account agilebits)"
    ```
  </Tab>
</Tabs>

To run the command `op vault list` in the account with the shorthand `personal`:

```shell theme={null}
op vault list --account personal
```

Then to run the same command in the `agilebits` account:

```shell theme={null}
op vault list --account agilebits
```

You can also [specify a custom shorthand](#set-a-custom-account-shorthand) when you add an account.

## Troubleshooting

If you've already [turned on the 1Password app integration](/cli/get-started/#step-2-turn-on-the-1password-desktop-app-integration), you'll need to turn it off before you can add an account on the command line.

## Learn more

* [Integrate 1Password CLI with the 1Password desktop app](/cli/app-integration/)
* [About the security of the 1Password desktop app integration](/cli/app-integration-security/)
* [Developer quickstart](/get-started/developer-quickstart)

## Appendix: Find an account shorthand or ID

1Password CLI uses account shorthands to refer to each of the accounts you've added. To see all the accounts you've added, their shorthands, and account details, run `op account list`.

<CodeResult>
  ```shell theme={null}
  op account list
  #code-result
  SHORTHAND       URL                                     EMAIL                           USER UUID
  my              https://my.1password.com                wendy.c.appleseed@gmail.com     A10S...
  agilebits       https://agilebits-inc.1password.com     wendy_appleseed@agilebits.com   ONJ9...
  ```
</CodeResult>

You can use the shorthand, sign-in address, or user ID to refer to a specific account in your commands.
