Skip to content

Commit cb4ea4b

Browse files
committed
Add authentication how-to
1 parent be96f7a commit cb4ea4b

File tree

4 files changed

+81
-1
lines changed

4 files changed

+81
-1
lines changed

docs/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- [Cancel a Workflow](./core/how-to/cancel-workflow.md)
3333
- [View Job Logs](./core/how-to/view-job-logs.md)
3434
- [Debug a Failed Job](./core/how-to/debug-failed-job.md)
35+
- [Set Up Authentication](./core/how-to/set-up-authentication.md)
3536
- [Check Resource Utilization](./core/how-to/check-resource-utilization.md)
3637
- [View Resource Plots](./core/how-to/view-resource-plots.md)
3738
- [Parameterize Jobs with Files](./core/how-to/parameterize-with-files.md)

docs/src/core/how-to/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Step-by-step guides for common tasks.
66
- [Cancel a Workflow](./cancel-workflow.md) - Stopping running workflows
77
- [View Job Logs](./view-job-logs.md) - Accessing job output
88
- [Debug a Failed Job](./debug-failed-job.md) - Troubleshooting failures
9+
- [Set Up Authentication](./set-up-authentication.md) - Saving credentials for CLI access
910
- [Check Resource Utilization](./check-resource-utilization.md) - Monitoring resource usage
1011
- [View Resource Plots](./view-resource-plots.md) - Visualizing resource metrics
1112
- [Parameterize Jobs with Files](./parameterize-with-files.md) - Using file-based parameters
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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

docs/src/getting-started/installation.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ echo 'export PATH="/scratch/dthom/torc/latest:$PATH"' >> ~/.bashrc
7474
```
7575

7676
**Shared server**: A `torc-server` instance runs on a dedicated VM within the Kestrel environment at
77-
`torc.hpc.nrel.gov`. Contact Daniel Thom if you would like to create an access group to store
77+
`torc.hpc.nrel.gov`. See [How to Set Up Authentication](../core/how-to/set-up-authentication.md) to
78+
configure your credentials. Contact Daniel Thom if you would like to create an access group to store
7879
private workflows for your team.
7980

8081
```bash

0 commit comments

Comments
 (0)