-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add ssh tool for remote command execution over SSH #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b341a94
feat: add ssh tool for read-only remote diagnostics
imaustink 6cc06ba
Merge remote-tracking branch 'origin/main' into worktree-feat+ssh-tool
imaustink 419e5c1
feat(ssh): make host allowlist and ssh_config resolution independent
imaustink 277f208
feat(ssh): wire prod sshTool via SSH_CONFIG aliases, disable allowlist
imaustink ca22e2c
fix: address ssh tool review findings (ip/find, CI, allowlist gap)
imaustink 505aa92
feat(ssh): make the command allowlist configurable, wide open for prod
imaustink a12c321
fix(ssh): drop kube/db nodes from prod, add console
imaustink 8dfae0d
fix(ssh): update console host to its new IP (.83 -> .71)
imaustink 570e19a
fix(ssh): flag that id_rsa isn't authorized on console
imaustink File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
charts/community-components/templates/serviceaccount-ssh.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| {{- if and .Values.sshTool.enabled .Values.sshTool.serviceAccount.create }} | ||
| apiVersion: v1 | ||
| kind: ServiceAccount | ||
| metadata: | ||
| name: {{ .Values.sshTool.serviceAccountName }} | ||
| namespace: {{ .Release.Namespace }} | ||
| labels: | ||
| {{- include "tools.labels" . | nindent 4 }} | ||
| {{- with .Values.sshTool.serviceAccount.annotations }} | ||
| annotations: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| {{- with .Values.imagePullSecrets }} | ||
| imagePullSecrets: | ||
| {{- toYaml . | nindent 2 }} | ||
| {{- end }} | ||
| automountServiceAccountToken: {{ .Values.sshTool.serviceAccount.automount }} | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| {{- if .Values.sshTool.enabled }} | ||
| {{- if and (not .Values.sshTool.allowedHosts) (not .Values.sshTool.sshConfig) }} | ||
| {{- fail "sshTool requires at least one of allowedHosts or sshConfig -- with neither set this tool would have no boundary on which target it dials" }} | ||
| {{- end }} | ||
| {{- $wideOpen := eq .Values.sshTool.allowedCommands "*" }} | ||
| apiVersion: {{ .Values.crdApiVersion }} | ||
| kind: Tool | ||
| metadata: | ||
| name: ssh | ||
| labels: | ||
| {{- include "tools.labels" . | nindent 4 }} | ||
| spec: | ||
| description: >- | ||
| {{- if $wideOpen }} | ||
| Runs a single command over SSH against a target resolved via an optional | ||
| ssh_config-style Host list and/or restricted to a fixed allowlist, for | ||
| managing infrastructure outside the cluster. allowedCommands is "*" for | ||
| this deployment -- there is NO command allowlist here beyond the | ||
| remote-shell-injection charset check, so this Tool can write, delete, | ||
| and restart services on any target it can reach, not just diagnose them. | ||
| {{- else }} | ||
| Runs a single read-only diagnostic command (df, ps, uptime, systemctl | ||
| status, docker ps/logs/inspect, journalctl, ...) over SSH against a | ||
| target resolved via an optional ssh_config-style Host list and/or | ||
| restricted to a fixed allowlist, for debugging infrastructure outside | ||
| the cluster. Strictly read-only: an in-tool command allowlist blocks any | ||
| write/restart/delete action or interactive shell. | ||
| {{- end }} | ||
| input: >- | ||
| A single "<target> <command> [args...]" line, where <target> is either | ||
| "user@host[:port]" or an alias resolved via the configured ssh_config | ||
| Host list (e.g. "nas.kurpuis.internal df -h", "kube0 systemctl status | ||
| docker"). | ||
| {{- if $wideOpen }} | ||
| Any remote command is accepted (no command allowlist in this | ||
| deployment); if a target allowlist is configured the resolved target | ||
| must still match it. | ||
| {{- else }} | ||
| Only a fixed set of read-only diagnostic commands are accepted, and if a | ||
| target allowlist is configured the resolved target must match it; | ||
| anything else is rejected before it reaches the target. | ||
| {{- end }} | ||
| output: >- | ||
| The remote command's own stdout, wrapped in a fenced code block. | ||
| allowedRoles: | ||
| {{- if $wideOpen }} | ||
| - writer | ||
| {{- else }} | ||
| - reader | ||
| {{- end }} | ||
| tier: standard | ||
| image: {{ .Values.sshTool.image | quote }} | ||
| serviceAccountName: {{ .Values.sshTool.serviceAccountName | quote }} | ||
| env: | ||
| {{- if .Values.sshTool.allowedHosts }} | ||
| - name: SSH_ALLOWED_HOSTS | ||
| value: {{ .Values.sshTool.allowedHosts | quote }} | ||
| {{- end }} | ||
| {{- if .Values.sshTool.sshConfig }} | ||
| - name: SSH_CONFIG | ||
| value: {{ .Values.sshTool.sshConfig | quote }} | ||
| {{- end }} | ||
| {{- if .Values.sshTool.defaultUser }} | ||
| - name: SSH_DEFAULT_USER | ||
| value: {{ .Values.sshTool.defaultUser | quote }} | ||
| {{- end }} | ||
| {{- if .Values.sshTool.allowedCommands }} | ||
| - name: SSH_ALLOWED_COMMANDS | ||
| value: {{ .Values.sshTool.allowedCommands | quote }} | ||
| {{- end }} | ||
| secretEnv: | ||
| - name: SSH_PRIVATE_KEY | ||
| secretRef: | ||
| name: {{ .Values.sshTool.secretName | quote }} | ||
| key: {{ .Values.sshTool.privateKeySecretKey | quote }} | ||
| - name: SSH_KNOWN_HOSTS | ||
| secretRef: | ||
| name: {{ .Values.sshTool.secretName | quote }} | ||
| key: {{ .Values.sshTool.knownHostsSecretKey | quote }} | ||
| {{- end }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR turns CI red.
.github/workflows/validate-crds.ymlrenders the chart withvalues-ci-all.yamland asserts every file undertemplates/appears in the output.tool-ssh.yamlandserviceaccount-ssh.yamlrender nothing there becausesshToolis disabled by default andvalues-ci-all.yamlwas not updated to enable it, so the "Assert every template was actually rendered" step exits 1 (this is the failingvalidatecheck on the PR).🤖 Prompt to fix this with an AI agent