1
0
Fork
You've already forked ssh-action
0
A Forgejo Action for executing commands and scripts on a remote host via SSH in CI/CD pipelines
  • Shell 100%
2025年03月23日 17:05:03 +01:00
action.yml Add action 2025年03月21日 16:52:49 +01:00
entrypoint.sh Add output handling 2025年03月23日 17:05:03 +01:00
LICENSE Initial commit 2025年03月21日 15:43:39 +00:00
README.md Update readme 2025年03月23日 13:20:16 +01:00

SSH Forgejo Action

A Forgejo Action to execute commands or scripts on a remote server via SSH.

Features

  • Securely connects to a remote server using SSH.
  • Executes inline commands or an external script.
  • Supports custom SSH ports.
  • Uses environment variables for sensitive credentials.

Usage

Inputs

Name Required Description
host The hostname or IP address of the remote server.
username The SSH username.
key The private SSH key for authentication.
port The SSH port (default is 22).
script Inline commands or the path to a script to execute.

Example Workflow

name:Execute Commands or Script on Remote Hoston:push:branches:- mainjobs:execute-commands:runs-on:ubuntu-lateststeps:- name:Checkout repositoryuses:actions/checkout@v2- name:Execute Inline Commands on Remote Hostuses:https://codeberg.org/latzo/ssh-action@v1with:host:${{ secrets.HOST }}username:${{ secrets.USERNAME }}key:${{ secrets.KEY }}port:${{ secrets.PORT }}script:| whoami
 ls -al- name:Execute Script on Remote Hostuses:https://codeberg.org/latzo/ssh-action@v1with:host:${{ secrets.HOST }}username:${{ secrets.USERNAME }}key:${{ secrets.KEY }}port:${{ secrets.PORT }}script:/path/to/script.sh

How It Works

  1. The action connects to the remote server using SSH.
  2. If the script input contains inline commands, they are executed directly.
  3. If script is a file path, the script is copied to the remote server and executed.
  4. The SSH key is securely passed as an environment variable and deleted after execution.

Security Considerations

  • Use GitHub Secrets: Always store sensitive information (such as key, host, username) as GitHub Secrets.
  • Restrict SSH Access: Ensure that the SSH key used for authentication has the necessary but minimal permissions.

License

This project is licensed under the GNU AFFERO GENERAL PUBLIC LICENSE