2024-07-03 04:02:51 +08:00
|
|
|
name: 'SSH and Execute Command'
|
|
|
|
description: 'SSH into a remote server and execute a command'
|
|
|
|
inputs:
|
|
|
|
host:
|
|
|
|
description: 'The host of the remote server'
|
|
|
|
required: true
|
|
|
|
user:
|
|
|
|
description: 'The username for the remote server'
|
2024-07-03 04:04:32 +08:00
|
|
|
required: false
|
|
|
|
default: 'root'
|
2024-07-03 04:02:51 +08:00
|
|
|
key:
|
|
|
|
description: 'The SSH key for the remote server'
|
|
|
|
required: true
|
|
|
|
command:
|
|
|
|
description: 'The command to execute on the remote server'
|
|
|
|
required: true
|
|
|
|
port:
|
|
|
|
description: 'The port for SSH connection'
|
|
|
|
required: false
|
|
|
|
default: '22'
|
|
|
|
runs:
|
|
|
|
using: 'docker'
|
|
|
|
image: 'docker://liy36/ubuntu-ssh:24.04'
|
|
|
|
steps:
|
|
|
|
- run: |
|
|
|
|
mkdir -p ~/.ssh/
|
|
|
|
echo "${{ inputs.key }}" > ~/.ssh/id_rsa
|
|
|
|
chmod 600 ~/.ssh/id_rsa
|
|
|
|
ssh -o StrictHostKeyChecking=no -p ${{ inputs.port }} ${{ inputs.user }}@${{ inputs.host }} "${{ inputs.command }}"
|