feat(core): implement notebook parsing and safe parameter rendering (#1)
Parse YAML frontmatter, shell steps and conditional sections with source ranges and diagnostics. Resolve typed defaults and runtime values through one script substitution path, keeping secrets env-only and validating artifact metadata. Add yaml for standards-compliant frontmatter parsing and bounded alias handling rather than implementing YAML locally. Cover the spec example and edge cases with 59 core tests, including 256 POSIX shell quoting round trips.
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: New server SSH key
|
||||
params:
|
||||
host: { type: host, required: true, label: Target server }
|
||||
user: { type: name, required: true, default: admin, label: Login user }
|
||||
keyname: { type: name, default: "id_ed25519_{{host}}" }
|
||||
---
|
||||
|
||||
# New server SSH key
|
||||
|
||||
Creates a key pair for **{{user}}** on **{{host}}** and authorizes it.
|
||||
|
||||
```sh {check host="{{host}}" title="User exists"}
|
||||
id {{user}}
|
||||
```
|
||||
|
||||
```sh {check host="{{host}}" title="Password login disabled"}
|
||||
sshd -T | grep -qx 'passwordauthentication no'
|
||||
```
|
||||
|
||||
```sh {run on=local id=keygen title="Generate key pair" artifacts="{{keyname}},{{keyname}}.pub"}
|
||||
ssh-keygen -q -t ed25519 -N '' -C {{user}}@{{host}} -f {{keyname}}
|
||||
```
|
||||
|
||||
```sh {run host="{{host}}" id=authorize title="Authorize key" confirm upload="{{keyname}}.pub:/tmp/new_key.pub"}
|
||||
install -d -m 700 -o {{user}} -g {{user}} ~{{user}}/.ssh
|
||||
cat /tmp/new_key.pub >> ~{{user}}/.ssh/authorized_keys
|
||||
rm /tmp/new_key.pub
|
||||
```
|
||||
|
||||
:::after{step=keygen}
|
||||
Download the private key above, then save it:
|
||||
|
||||
- **Linux:** `~/.ssh/{{keyname}}`, then `chmod 600 ~/.ssh/{{keyname}}`
|
||||
- **Windows:** `C:\Users\<you>\.ssh\{{keyname}}`
|
||||
:::
|
||||
Reference in New Issue
Block a user