Skip to content

Commit 11ec003

Browse files
committed
fix #124
1 parent 564bf5b commit 11ec003

File tree

6 files changed

+1145
-30
lines changed

6 files changed

+1145
-30
lines changed

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,44 @@ jobs:
7171
# Prints: Secret: ***
7272
```
7373

74+
### Loading SSH Keys
75+
76+
When loading SSH private keys from 1Password, you may need to convert them to OpenSSH format. 1Password stores SSH keys in PKCS8/PKCS1 format (`-----BEGIN PRIVATE KEY-----`), but many SSH tools require OpenSSH format (`-----BEGIN OPENSSH PRIVATE KEY-----`).
77+
78+
```yml
79+
on: push
80+
jobs:
81+
deploy:
82+
runs-on: ubuntu-latest
83+
steps:
84+
- uses: actions/checkout@v4
85+
86+
- name: Load SSH key
87+
id: load_ssh_key
88+
uses: 1password/load-secrets-action@v3
89+
with:
90+
# Convert SSH keys from PKCS format to OpenSSH format
91+
convert-ssh-keys: true
92+
env:
93+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
94+
SSH_PRIVATE_KEY: op://vault/server/private_key
95+
96+
- name: Use SSH key
97+
run: |
98+
mkdir -p ~/.ssh
99+
echo "${{ steps.load_ssh_key.outputs.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
100+
chmod 600 ~/.ssh/id_ed25519
101+
ssh -i ~/.ssh/id_ed25519 [email protected]
102+
```
103+
104+
**Notes:**
105+
- The `convert-ssh-keys` option requires `ssh-keygen` to be available (pre-installed on all GitHub-hosted runners)
106+
- Conversion automatically detects PKCS-format private keys (headers: `BEGIN PRIVATE KEY`, `BEGIN RSA PRIVATE KEY`, `BEGIN EC PRIVATE KEY`) and converts them to OpenSSH format
107+
- Keys already in OpenSSH format are not modified
108+
- Encrypted private keys are skipped with a warning (they require a passphrase to convert)
109+
- PEM certificates (`BEGIN CERTIFICATE`) are not affected
110+
- **Important**: Any unencrypted PEM private key will be converted when this option is enabled, regardless of whether it's intended for SSH use. Only enable this option if you specifically need OpenSSH format keys.
111+
74112
## 💙 Community & Support
75113

76114
- File an [issue](https://github.com/1Password/load-secrets-action/issues) for bugs and feature requests.

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ inputs:
1111
export-env:
1212
description: Export the secrets as environment variables
1313
default: "false"
14+
convert-ssh-keys:
15+
description: Convert SSH private keys from PKCS format to OpenSSH format. 1Password stores SSH keys in PKCS8/PKCS1 format, but some tools require OpenSSH format. Requires ssh-keygen to be available.
16+
default: "false"
1417
version:
1518
description: Specify which 1Password CLI version to install. Defaults to "latest".
1619
default: "latest"

0 commit comments

Comments
 (0)