|
| 1 | +# How to Set Up Authentication |
| 2 | + |
| 3 | +Configure your Torc credentials so that CLI commands authenticate automatically. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +Your server administrator must have enabled authentication on the Torc server. If you receive |
| 8 | +"Authentication required" errors, follow the steps below. |
| 9 | + |
| 10 | +## Step 1: Generate a Password Hash |
| 11 | + |
| 12 | +Run `torc-htpasswd hash` on your machine. It prompts for your password securely (nothing appears on |
| 13 | +screen): |
| 14 | + |
| 15 | +```bash |
| 16 | +torc-htpasswd hash |
| 17 | +``` |
| 18 | + |
| 19 | +``` |
| 20 | +Password for 'alice': |
| 21 | +Confirm password for 'alice': |
| 22 | +Hashing password (cost=12)... |
| 23 | +alice:$2b$12$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| 24 | +Send the line above to your server administrator. |
| 25 | +``` |
| 26 | + |
| 27 | +The hash is safe to share — it cannot be used to recover your password. |
| 28 | + |
| 29 | +## Step 2: Send the Hash to Your Administrator |
| 30 | + |
| 31 | +Send the output line (`alice:$2b$12$...`) to your server administrator through any channel (email, |
| 32 | +Slack, etc.). They will add it to the server's htpasswd file. |
| 33 | + |
| 34 | +## Step 3: Save Your Password Persistently |
| 35 | + |
| 36 | +**Create the credentials file** using `read -s` so the password never appears on screen or in shell |
| 37 | +history: |
| 38 | + |
| 39 | +```bash |
| 40 | +mkdir -p ~/.config/torc |
| 41 | +( |
| 42 | + read -s -p "Enter Torc password: " _pw && echo |
| 43 | + printf 'export TORC_PASSWORD="%s"\n' "$_pw" |
| 44 | +) > ~/.config/torc/credentials |
| 45 | +chmod 600 ~/.config/torc/credentials |
| 46 | +``` |
| 47 | + |
| 48 | +If your username on the server differs from your system `$USER`, also add it: |
| 49 | + |
| 50 | +```bash |
| 51 | +echo 'export TORC_USERNAME="alice"' >> ~/.config/torc/credentials |
| 52 | +``` |
| 53 | + |
| 54 | +**Source the file from your shell configuration** so it loads automatically. Add this line to |
| 55 | +`~/.bashrc` or `~/.zshrc`: |
| 56 | + |
| 57 | +```bash |
| 58 | +echo '[ -f ~/.config/torc/credentials ] && source ~/.config/torc/credentials' >> ~/.bashrc |
| 59 | +source ~/.config/torc/credentials |
| 60 | +``` |
| 61 | + |
| 62 | +## Step 4: Verify |
| 63 | + |
| 64 | +```bash |
| 65 | +torc workflows list |
| 66 | +``` |
| 67 | + |
| 68 | +## Protecting Your Credentials |
| 69 | + |
| 70 | +- The credentials file is already restricted (`chmod 600`) from step 3 |
| 71 | +- **Never pass `--password` on the command line** — it appears in shell history and process lists |
| 72 | +- **Do not commit** `~/.config/torc/credentials` or any file containing passwords to version control |
| 73 | + |
| 74 | +## See Also |
| 75 | + |
| 76 | +- [Environment Variables](../reference/environment-variables.md) — All Torc environment variables |
| 77 | +- [CLI Reference](../reference/cli.md) — Global `--username` and `--password` flags |
0 commit comments