Skip to content
Skills Library
DevOps & cloud · Analysis

bash-herestring-newline-secrets

/bash-herestring-newline-secrets

Fix password/secret authentication failures caused by trailing newlines when creating Google Cloud secrets (or similar) with bash here-strings. Use when: (1) Password authentication fails with correct password, (2) Secret created with `<<< "value"` syntax, (3) Error like "password authentication failed" or "invalid token" despite correct value. Bash here-strings (`<<<`) add a trailing newline that corrupts secrets.

Licence
AGPL-3.0
Last repository change
27.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.

Licence

AGPL-3.0, copyleft: przeróbki udostępniane innym muszą mieć tę samą licencję.

What it does and when to use it

Fix password/secret authentication failures caused by trailing newlines when creating Google Cloud secrets (or similar) with bash here-strings. Use when: (1) Password authentication fails with correct password, (2) Secret created with `<<< "value"` syntax, (3) Error like "password authentication failed" or "invalid token" despite correct value. Bash here-strings (`<<<`) add a trailing newline that corrupts secrets.

Triggers from the description

valuepassword authentication failedinvalid token
Original author description

Fix password/secret authentication failures caused by trailing newlines when creating Google Cloud secrets (or similar) with bash here-strings. Use when: (1) Password authentication fails with correct password, (2) Secret created with `<<< "value"` syntax, (3) Error like "password authentication failed" or "invalid token" despite correct value. Bash here-strings (`<<<`) add a trailing newline that corrupts secrets.

How it works

  1. Problem
  2. Context / Trigger Conditions
  3. Solution
  4. Verification
  5. Example
  6. Notes
  7. References
Original SKILL.md headings · 84 lines, 378 words
SKILL.md preview
---
name: bash-herestring-newline-secrets
description: |
  Fix password/secret authentication failures caused by trailing newlines when creating
  Google Cloud secrets (or similar) with bash here-strings. Use when: (1) Password
  authentication fails with correct password, (2) Secret created with `<<< "value"` syntax,
  (3) Error like "password authentication failed" or "invalid token" despite correct value.
  Bash here-strings (`<<<`) add a trailing newline that corrupts secrets.
author: Claude Code
version: 1.0.0
date: 2026-01-31
---

# Bash Here-String Newline in Secrets

## Problem
When creating secrets using bash here-strings (`<<<`), a trailing newline is silently
appended to the value. This causes authentication failures with misleading error messages
that suggest the password/token is wrong when it's actually correct—just with an extra
newline character.

## Context / Trigger Conditions
- Secret created with: `gcloud secrets create NAME --data-file=- <<< "value"`
- Or similar: `echo "value" | gcloud secrets create...` (echo adds newline by default)
- Error messages like:
  - "password authentication failed for user X"
  - "invalid token"
  - "authentication failed"
- The secret value appears correct when viewed
- Works locally but fails when secret is used

## Solution

**Wrong (adds newline):**
```bash
gcloud secrets create my-secret --data-file=- <<< "mypassword"
echo "mypassword" | gcloud secrets create my-secret --data-file=-
```

**Correct (no newline):**
```bash
echo -n "mypassword" | gcloud secrets create my-secret --data-file=-
printf '%s' "mypassword" | gcloud secrets create my-secret --data-file=-
```

**To fix an existing secret:**
```bash
echo -n "correct-value" | gcloud secrets versions add my-secret --data-file=-
```

## Verification

Check the secret length to detect trailing newline:
```bash
# Get secret and count bytes
gcloud secrets versions access latest --secret=my-secret | wc -c
# Compare to expected length (password length, not password length + 1)
```

Or use `xxd` to see the actual bytes:
```bash
gcloud secrets versions access latest --secret=my-secret | xxd | tail -1
# Look for '0a' (newline) at the end
```

## Example

**Symptom:**
```
Database connection test failed: password authentication failed for user "crawler"
```

**Investigation:**
```bash
$ gcloud secrets versions access latest --secret=my-db-password
mypassword
$ gcloud secrets versions access latest --secret=my-db-password | wc -c
11  # But password is only 10 characters!
```

**Fix:**
```bash
$ echo -n "mypassword" | gcloud secrets versions add my-db-password --data-file=-
Created version [2] of the secret [my-db-password].
```

## Notes
- This affects any system that uses secrets: databases, APIs, tokens, etc.
- The `<<<` here-string is a bash feature that ALWAYS adds a newline
- `echo` also adds a newline by default; use `echo -n` or `printf '%s'`
- Some systems trim whitespace from secrets, but many (like PostgreSQL) don't
- When debugging auth failures, always check for trailing whitespace first

## References
- Bash manual on here-strings: https://www.gnu.org/software/bash/manual/bash.html#Here-Strings

Versions

The database has no other skills named bash-herestring-newline-secrets.

Identical content appears in 1 other GitHub folders. We show one copy with the highest score.

Database snapshot: 13.11.2026 · package version 015de4dec381 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90secrets-doctor
    Use this skill when the user reports API authentication or missing credential issues in an aide-managed project, or when you observe authentication failures (401, 403, missing API key errors) that may be caused by aide's secret/env configuration. Triggers on: "can't access API",…
  • 100secrets
    Use this skill when a user wants to store, manage, or work with Goldsky secrets — the named credential objects used by pipeline sinks. This includes: creating a new secret from a connection string or credentials, listing or inspecting existing secrets, updating or rotating…
  • 100fix-trailing-newlines
    Fix SA1518 StyleCop violations by removing trailing newlines from .cs, .xaml, .axaml, .csproj, .props, .targets, .editorconfig, .slnx, .sln, and .json files. Targets projects where .editorconfig has insert_final_newline = false. Use when SA1518 violations appear, trailing…
  • 100hyprland-secret-prompt
    Collect an API key, token, password, or other credential through a native masked Hyprland dialog and save a private Bash export file. Use when a user needs to enter a secret locally without putting it in chat, command arguments, or tool output.
  • 100cloud-run-job-cloudsql-setup
    Set up Cloud Run Jobs with CloudSQL connection. Use when: (1) Deploying long-running batch jobs that need database access, (2) Errors like "Cloud SQL Proxy not found" in container, (3) "password authentication failed" despite correct credentials, (4) Job creation fails with…
  • 100gcp-secret-manager
    Secure secrets in Google Cloud Secret Manager. Configure IAM policies, integrate with GKE, and manage secret versions. Use when managing secrets in GCP environments.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.