# Create client credentials

### Preparation

For a mass deployment of clients, where each client shall use its own `client_id` and `password`, proceed as follows:

1. Generate an API key with scope `clients`-auth.
2. Go to client access and generate a pairing script for any of the clients.
3. Download the bash or PowerShell script to your desktop, but don't execute it.
4. Open the scripts with an editor and go to the line where variables `CLIENT_ID` / `$client_id` and `PASSWORD` / `$password` are defined.
5. Delete the lines and replace with the below snippets. Each time you execute the script, new client credentials are created via an API call.
6. Now copy this script to new clients and execute.

<div><figure><img src="/files/qKWK9DqD1QLNpdKlpus9" alt="Generate client credentials on Linux"><figcaption><p>On Linux</p></figcaption></figure> <figure><img src="/files/g9dSbMW1cT7QZiOSwPpt" alt=""><figcaption><p>On Windows</p></figcaption></figure></div>

### Generate client credentials on Windows with PowerShell

```powershell
#
# Create new client credentials
#
$apiToken = "xxxxx_b4306692-389c-4f4b-8c3c-50638ef07086" # Use token with 'clients-auth' scope
$apiUrl = "https://rport.example.com:443/api/v1/clients-auth"
$apiUser = "john"

$password = (-join ((48..57) + (97..122) | Get-Random -Count 14 | % {[char]$_}))
$client_id = $env:computername
$body = @{
    id=$client_id
    password=$password
}
$json = $body|ConvertTo-Json
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $apiUser,$apiToken)))
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization = "Basic $base64AuthInfo"} -Method Post -Body $json -ContentType 'application/json'

```

### Generate client credentials on Linux with bash

```bash
API_TOKEN="xxxxx_8fdef130-6597-4522-ae67-62feabfcf05d"
API_USER="john"
API_URL="https://rport.example.com:443/api/v1/clients-auth"

PASSWORD=$(openssl rand -hex 10)
CLIENT_ID=$(hostname -f)  # or use /etc/machine-id
BODY="{
    \"id\":\"${CLIENT_ID}\",
    \"password\":\"${PASSWORD}\"
}"
curl -fsu ${API_USER}:${API_TOKEN} ${API_URL} -H "Content-Type: application/json" -d "${BODY}"
```


---

# Agent Instructions: 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://kb.rport.io/digging-deeper/using-the-api/create-client-credentials.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.
