From 71e420815f13fa3a32fbe3397daf0f44dfe847fa Mon Sep 17 00:00:00 2001 From: Laurent Rochette Date: Mon, 23 Oct 2023 15:50:51 -0700 Subject: [PATCH 1/7] initial version Signed-off-by: Laurent Rochette --- incubating/ssh/CHANGELOG.md | 5 ++ incubating/ssh/images/ssh.svg | 1 + incubating/ssh/step.yaml | 102 ++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 incubating/ssh/CHANGELOG.md create mode 100644 incubating/ssh/images/ssh.svg create mode 100644 incubating/ssh/step.yaml diff --git a/incubating/ssh/CHANGELOG.md b/incubating/ssh/CHANGELOG.md new file mode 100644 index 000000000..390952574 --- /dev/null +++ b/incubating/ssh/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## [0.0.1] - 2023-10-23 + +- initial version diff --git a/incubating/ssh/images/ssh.svg b/incubating/ssh/images/ssh.svg new file mode 100644 index 000000000..34a861680 --- /dev/null +++ b/incubating/ssh/images/ssh.svg @@ -0,0 +1 @@ +AWS-Systems-Manager_Parameter-Store_light-bg \ No newline at end of file diff --git a/incubating/ssh/step.yaml b/incubating/ssh/step.yaml new file mode 100644 index 000000000..abcc7e1b7 --- /dev/null +++ b/incubating/ssh/step.yaml @@ -0,0 +1,102 @@ +kind: step-type +version: '1.0' +metadata: + name: ssh + version: 0.0.1 + isPublic: true + description: a basic ssh plugin + sources: + - https://github.com/codefresh-io/steps/tree/master/incubating/ssh + stage: incubating + maintainers: + - name: Laurent Rochette + - email: laurent.rochette@codefresh.io + categories: + - utilities + official: true + tags: [] + icon: + type: image + size: + large: + url: >- + https://raw.githubusercontent.com/codefresh-io/steps/master/incubating/ssh/images/ssh.png + examples: + - description: Run a ssh command + workflow: + ssh: + title: run ssh command + type: ssh + stage: build + arguments: + SSH_KEY: ${{KEY}} + SSH_USER: ${{ArgumentParser}} + SSH_HOST: computer.domain.com + SSH_COMMANDS: + - ls + - echo hello world + +spec: + arguments: |- + { + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": true, + "patterns": [], + "required": [ + "SSH_KEY", + "SSH_USER", + "SSH_HOST", + "SSH_COMMANDS" + ], + "properties": { + "SSH_IMAGE": { + "type": "string", + "default": "quay.io/wbitt/network-multitool", + "description": "The ssh container image registry/image for the step." + }, + "SSH_IMAGE_VERSION": { + "type": "string", + "default": "latest", + "description": "Version of the ssh image to use, Docker image tag." + }, + "SSH_KEY": { + "type": "string", + "description": "The ssh key to connect to a remote instance" + }, + "SSH_USER": { + "type": "string", + "description": "The username to log into the instance" + }, + "SSH_HOST": { + "type": "string", + "description": "The instance to connect to" + }, + "SSH_COMMANDS": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Commands to execute" + } + } + } + stepsTemplate: |- + ssh: + title: Execute commands over ssh + image: '[[.Arguments.SSH_IMAGE]]:[[.Arguments.SSH_IMAGE_VERSION]]' + commands: + - mkdir /root/.ssh + - echo ${{SSH_KEY}} | base64 -d > /root/.ssh/id_rsa ## Value of ${{SSH_KEY}} is base64 encoded + - chmod 600 ~/.ssh/id_rsa + - eval $(ssh-agent -s) + - ssh-add ~/.ssh/id_rsa + - ssh -o "StrictHostKeyChecking no" ${{MY_USER}}@${{MY_HOST}} + [[ range $arg := .Arguments.commands ]] + - ssh ${{MY_USER}}@${{MY_HOST}} '[[ $arg ]]' + [[ end ]] + + delimiters: + left: '[[' + right: ']]' From 7ef4e3ac05af12faa1af39dfabd4607af0f6527d Mon Sep 17 00:00:00 2001 From: Laurent Rochette Date: Mon, 23 Oct 2023 17:06:49 -0700 Subject: [PATCH 2/7] fix indentation --- incubating/ssh/step.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/incubating/ssh/step.yaml b/incubating/ssh/step.yaml index abcc7e1b7..bfda1aa5f 100644 --- a/incubating/ssh/step.yaml +++ b/incubating/ssh/step.yaml @@ -1,10 +1,10 @@ kind: step-type version: '1.0' metadata: - name: ssh - version: 0.0.1 - isPublic: true - description: a basic ssh plugin + name: ssh + version: 0.0.1 + isPublic: true + description: Run commands over ssh sources: - https://github.com/codefresh-io/steps/tree/master/incubating/ssh stage: incubating @@ -96,7 +96,7 @@ spec: [[ range $arg := .Arguments.commands ]] - ssh ${{MY_USER}}@${{MY_HOST}} '[[ $arg ]]' [[ end ]] - + delimiters: left: '[[' right: ']]' From b91086dc9dc73e2fd2bcd422cb2f652f2d304176 Mon Sep 17 00:00:00 2001 From: Laurent Rochette Date: Tue, 24 Oct 2023 14:45:17 -0700 Subject: [PATCH 3/7] image does not exist on quay.io --- incubating/ssh/step.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/incubating/ssh/step.yaml b/incubating/ssh/step.yaml index bfda1aa5f..e5a879004 100644 --- a/incubating/ssh/step.yaml +++ b/incubating/ssh/step.yaml @@ -53,7 +53,7 @@ spec: "properties": { "SSH_IMAGE": { "type": "string", - "default": "quay.io/wbitt/network-multitool", + "default": "docker.io/wbitt/network-multitool", "description": "The ssh container image registry/image for the step." }, "SSH_IMAGE_VERSION": { From 1c8ae81b59cb882be12f9bc1ce18a25ef370550d Mon Sep 17 00:00:00 2001 From: Laurent Rochette Date: Tue, 24 Oct 2023 15:03:44 -0700 Subject: [PATCH 4/7] add missing environment --- incubating/ssh/step.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/incubating/ssh/step.yaml b/incubating/ssh/step.yaml index e5a879004..4b6dc2a27 100644 --- a/incubating/ssh/step.yaml +++ b/incubating/ssh/step.yaml @@ -86,6 +86,10 @@ spec: ssh: title: Execute commands over ssh image: '[[.Arguments.SSH_IMAGE]]:[[.Arguments.SSH_IMAGE_VERSION]]' + environment: + - SSK_KEY=[[ .Arguments.SSH_KEY ]] + - MY_USER=[[ .Arguments.SSH_USER ]] + - MY_HOST=[[ .Arguments.SSH_HOST ]] commands: - mkdir /root/.ssh - echo ${{SSH_KEY}} | base64 -d > /root/.ssh/id_rsa ## Value of ${{SSH_KEY}} is base64 encoded From 97bd30e57ac633d9ac913a6dd2bcb8ff0c9e055d Mon Sep 17 00:00:00 2001 From: Laurent Rochette Date: Tue, 24 Oct 2023 15:12:22 -0700 Subject: [PATCH 5/7] debug --- incubating/ssh/step.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/incubating/ssh/step.yaml b/incubating/ssh/step.yaml index 4b6dc2a27..2d9802627 100644 --- a/incubating/ssh/step.yaml +++ b/incubating/ssh/step.yaml @@ -91,6 +91,7 @@ spec: - MY_USER=[[ .Arguments.SSH_USER ]] - MY_HOST=[[ .Arguments.SSH_HOST ]] commands: + - env - mkdir /root/.ssh - echo ${{SSH_KEY}} | base64 -d > /root/.ssh/id_rsa ## Value of ${{SSH_KEY}} is base64 encoded - chmod 600 ~/.ssh/id_rsa From 05b55ec318cabd81064df766e9e4319b8d738955 Mon Sep 17 00:00:00 2001 From: Laurent Rochette Date: Mon, 30 Oct 2023 14:13:35 -0700 Subject: [PATCH 6/7] Upgraded version fixed last remaining issues Signed-off-by: Laurent Rochette --- incubating/ssh/step.yaml | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/incubating/ssh/step.yaml b/incubating/ssh/step.yaml index 2d9802627..37e7b435e 100644 --- a/incubating/ssh/step.yaml +++ b/incubating/ssh/step.yaml @@ -2,7 +2,7 @@ kind: step-type version: '1.0' metadata: name: ssh - version: 0.0.1 + version: 1.0.0 isPublic: true description: Run commands over ssh sources: @@ -58,12 +58,12 @@ spec: }, "SSH_IMAGE_VERSION": { "type": "string", - "default": "latest", + "default": "extra", "description": "Version of the ssh image to use, Docker image tag." }, "SSH_KEY": { "type": "string", - "description": "The ssh key to connect to a remote instance" + "description": "The ssh key to connect to a remote instance, base64 encoded" }, "SSH_USER": { "type": "string", @@ -73,6 +73,11 @@ spec: "type": "string", "description": "The instance to connect to" }, + "SSH_PORT": { + "type": "string", + "default": 22, + "description": "The port to use to connect. Default is 22" + }, "SSH_COMMANDS": { "type": "array", "items": { @@ -87,19 +92,18 @@ spec: title: Execute commands over ssh image: '[[.Arguments.SSH_IMAGE]]:[[.Arguments.SSH_IMAGE_VERSION]]' environment: - - SSK_KEY=[[ .Arguments.SSH_KEY ]] - - MY_USER=[[ .Arguments.SSH_USER ]] - - MY_HOST=[[ .Arguments.SSH_HOST ]] + - SSH_KEY=[[ .Arguments.SSH_KEY ]] + - SSH_USER=[[ .Arguments.SSH_USER ]] + - HOST=[[ .Arguments.SSH_HOST ]] + - PORT=[[ .Arguments.SSH_PORT ]] commands: - - env - - mkdir /root/.ssh - - echo ${{SSH_KEY}} | base64 -d > /root/.ssh/id_rsa ## Value of ${{SSH_KEY}} is base64 encoded - - chmod 600 ~/.ssh/id_rsa - - eval $(ssh-agent -s) - - ssh-add ~/.ssh/id_rsa - - ssh -o "StrictHostKeyChecking no" ${{MY_USER}}@${{MY_HOST}} - [[ range $arg := .Arguments.commands ]] - - ssh ${{MY_USER}}@${{MY_HOST}} '[[ $arg ]]' + - mkdir /root/.ssh + - echo ${SSH_KEY} | base64 -d > /root/.ssh/id_rsa ## Value of ${SSH_KEY} is base64 encoded + - chmod 600 ~/.ssh/id_rsa + - eval $(ssh-agent -s) + - ssh-add ~/.ssh/id_rsa + [[ range $arg := .Arguments.SSH_COMMANDS ]] + - ssh -o "StrictHostKeyChecking no" -p ${PORT} ${SSH_USER}@${HOST} '[[ $arg ]]' [[ end ]] delimiters: From f011b8c7619a648680fab84c7c9eb152faba8a55 Mon Sep 17 00:00:00 2001 From: Laurent Rochette Date: Mon, 30 Oct 2023 14:14:15 -0700 Subject: [PATCH 7/7] Upgraded version fixed last remaining issues Signed-off-by: Laurent Rochette --- incubating/ssh/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/incubating/ssh/CHANGELOG.md b/incubating/ssh/CHANGELOG.md index 390952574..b4132af6b 100644 --- a/incubating/ssh/CHANGELOG.md +++ b/incubating/ssh/CHANGELOG.md @@ -1,5 +1,5 @@ # Changelog -## [0.0.1] - 2023-10-23 +## [1.0.0] - 2023-10-30 - initial version