Skip to content
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

ssh plugin #657

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions incubating/ssh/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## [1.0.0] - 2023-10-30

- initial version
1 change: 1 addition & 0 deletions incubating/ssh/images/ssh.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
111 changes: 111 additions & 0 deletions incubating/ssh/step.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
kind: step-type
version: '1.0'
metadata:
name: ssh
version: 1.0.0
isPublic: true
description: Run commands over ssh
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": "docker.io/wbitt/network-multitool",
"description": "The ssh container image registry/image for the step."
},
"SSH_IMAGE_VERSION": {
"type": "string",
"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, base64 encoded"
},
"SSH_USER": {
"type": "string",
"description": "The username to log into the instance"
},
"SSH_HOST": {
"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": {
"type": "string"
},
"description": "Commands to execute"
}
}
}
stepsTemplate: |-
ssh:
title: Execute commands over ssh
image: '[[.Arguments.SSH_IMAGE]]:[[.Arguments.SSH_IMAGE_VERSION]]'
environment:
- SSH_KEY=[[ .Arguments.SSH_KEY ]]
- SSH_USER=[[ .Arguments.SSH_USER ]]
- HOST=[[ .Arguments.SSH_HOST ]]
- PORT=[[ .Arguments.SSH_PORT ]]
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
[[ range $arg := .Arguments.SSH_COMMANDS ]]
- ssh -o "StrictHostKeyChecking no" -p ${PORT} ${SSH_USER}@${HOST} '[[ $arg ]]'
[[ end ]]

delimiters:
left: '[['
right: ']]'
Loading