Skip to content

Commit

Permalink
Merge branch 'appleboy:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
GammaGames authored Nov 22, 2024
2 parents 5b73b09 + 43d4ebb commit fbf2b78
Show file tree
Hide file tree
Showing 9 changed files with 205 additions and 131 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ jobs:
set -e
whoami
- name: ssh commands from a file
uses: ./
with:
host: ${{ env.REMOTE_HOST }}
username: linuxserver.io
password: password
port: 2222
script_path: testdata/test.sh

check-ssh-key:
runs-on: ubuntu-latest
steps:
Expand Down
41 changes: 25 additions & 16 deletions .github/workflows/stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
sleep 2
- name: ssh by username and password
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ env.REMOTE_HOST }}
username: linuxserver.io
Expand All @@ -42,6 +42,15 @@ jobs:
set -e
whoami
- name: ssh commands from a file
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ env.REMOTE_HOST }}
username: linuxserver.io
password: password
port: 2222
script_path: testdata/test.sh

check-ssh-key:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -86,7 +95,7 @@ jobs:
sleep 2
- name: ssh by private key
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ env.REMOTE_HOST }}
username: linuxserver.io
Expand All @@ -95,7 +104,7 @@ jobs:
script: whoami

- name: wrong password but correct key
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ env.REMOTE_HOST }}
username: linuxserver.io
Expand All @@ -105,7 +114,7 @@ jobs:
script: whoami

- name: correct password but wrong key
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ env.REMOTE_HOST }}
username: linuxserver.io
Expand All @@ -115,7 +124,7 @@ jobs:
script: whoami

- name: stop script if command error
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
continue-on-error: true
with:
host: ${{ env.REMOTE_HOST }}
Expand Down Expand Up @@ -174,7 +183,7 @@ jobs:
sleep 2
- name: ssh key passphrase
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ env.REMOTE_HOST }}
username: linuxserver.io
Expand All @@ -186,7 +195,7 @@ jobs:
ls -al
- name: missing ssh key passphrase
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
continue-on-error: true
with:
host: ${{ env.REMOTE_HOST }}
Expand All @@ -199,7 +208,7 @@ jobs:
# https://github.com/appleboy/ssh-action/issues/75#issuecomment-668314271
- name: Multiline SSH commands interpreted as single lines
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ env.REMOTE_HOST }}
username: linuxserver.io
Expand Down Expand Up @@ -277,7 +286,7 @@ jobs:
# https://github.com/appleboy/ssh-action/issues/85
- name: Deployment to multiple hosts with different ports
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
with:
host: "${{ env.REMOTE_HOST_01 }}:2222,${{ env.REMOTE_HOST_02 }}:2222"
username: linuxserver.io
Expand Down Expand Up @@ -331,7 +340,7 @@ jobs:
sleep 2
- name: testing id_ed25519 key
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ env.REMOTE_HOST }}
username: linuxserver.io
Expand Down Expand Up @@ -384,7 +393,7 @@ jobs:
sleep 2
- name: testing id_ed25519 key
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ env.REMOTE_HOST }}
username: linuxserver.io
Expand All @@ -395,7 +404,7 @@ jobs:
ls -al
- name: pass environment
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
env:
FOO: "BAR"
with:
Expand All @@ -409,7 +418,7 @@ jobs:
echo "I am $BAR, thanks"
- name: pass multiple environment
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
env:
FOO: "BAR"
BAR: "FOO"
Expand All @@ -428,7 +437,7 @@ jobs:
echo "port: $PORT"
- name: custom envs format
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
env:
FOO: "BAR"
AAA: "BBB"
Expand All @@ -446,7 +455,7 @@ jobs:
echo "I am $TEST_AAA, thanks"
- name: pass all ENV variables to script
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
env:
INPUT_FOO: "BAR"
INPUT_AAA: "BBB"
Expand All @@ -463,7 +472,7 @@ jobs:
echo "$GITHUB_REF"
- name: switch to root user
uses: appleboy/ssh-action@v1.0.3
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ env.REMOTE_HOST }}
username: linuxserver.io
Expand Down
55 changes: 34 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
[繁體中文](./README.zh-tw.md)
[简体中文](./README.zh-cn.md)

[GitHub Action](https://github.com/features/actions) for executing remote ssh commands.
[GitHub Action](https://github.com/features/actions) for executing remote SSH commands.

![ssh workflow](./images/ssh-workflow.png)

[![Actions Status](https://github.com/appleboy/ssh-action/workflows/remote%20ssh%20command/badge.svg)](https://github.com/appleboy/ssh-action/actions)
[![testing main branch](https://github.com/appleboy/ssh-action/actions/workflows/main.yml/badge.svg)](https://github.com/appleboy/ssh-action/actions/workflows/main.yml)

**Important**: Only support **Linux** [docker](https://www.docker.com/) container.

This thing is built using [Golang](https://go.dev) and [drone-ssh](https://github.com/appleboy/drone-ssh). 🚀
This project is built using [Golang](https://go.dev) and [drone-ssh](https://github.com/appleboy/drone-ssh). 🚀

## Input variables

Expand All @@ -35,6 +33,7 @@ See [action.yml](./action.yml) for more detailed information.
| fingerprint | SHA256 fingerprint of the host public key | |
| proxy_host | SSH proxy host | |
| proxy_port | SSH proxy port | 22 |
| proxy_protocol | SSH proxy protocol version (tcp, tcp4, tcp6) | tcp |
| proxy_username | SSH proxy username | |
| proxy_password | SSH proxy password | |
| proxy_passphrase | SSH proxy key passphrase | |
Expand All @@ -45,16 +44,17 @@ See [action.yml](./action.yml) for more detailed information.
| proxy_cipher | Allowed cipher algorithms for the proxy | |
| proxy_use_insecure_cipher | Include more ciphers with use_insecure_cipher for the proxy | false |
| script | Execute commands | |
| script_file | Execute commands from a file | |
| script_stop | Stop script after first failure | false |
| envs | Pass environment variables to shell script | |
| envs_format | Flexible configuration of environment value transfer | |
| debug | Enable debug mode | false |
| allenvs | pass the environment variables with prefix value of `GITHUB_` and `INPUT_` to the script | false |
| allenvs | Pass the environment variables with prefix value of `GITHUB_` and `INPUT_` to the script | false |
| request_pty | Request a pseudo-terminal from the server | false |

## Usage

Executing remote ssh commands.
Executing remote SSH commands.

```yaml
name: remote ssh command
Expand All @@ -66,10 +66,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@v1.1.0
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
username: linuxserver.io
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: whoami
Expand All @@ -81,7 +81,7 @@ output:
======CMD======
whoami
======END======
out: ***
linuxserver.io
===============================================
✅ Successfully executed commands to all hosts.
===============================================
Expand Down Expand Up @@ -182,7 +182,7 @@ ssh-keygen -t ed25519 -a 200 -C "your_email@example.com"

```yaml
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@v1.1.0
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
Expand All @@ -195,7 +195,7 @@ ssh-keygen -t ed25519 -a 200 -C "your_email@example.com"
```yaml
- name: executing remote ssh commands using ssh key
uses: appleboy/ssh-action@v1.1.0
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
Expand All @@ -208,7 +208,7 @@ ssh-keygen -t ed25519 -a 200 -C "your_email@example.com"
```yaml
- name: multiple command
uses: appleboy/ssh-action@v1.1.0
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
Expand All @@ -221,11 +221,24 @@ ssh-keygen -t ed25519 -a 200 -C "your_email@example.com"
![result](./images/output-result.png)
#### Commands from a file
```yaml
- name: file commands
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script_path: scripts/script.sh
```
#### Multiple Hosts
```diff
- name: multiple host
uses: appleboy/ssh-action@v1.1.0
uses: appleboy/ssh-action@v1.2.0
with:
- host: "foo.com"
+ host: "foo.com,bar.com"
Expand All @@ -243,7 +256,7 @@ The default value of `port` is `22`.

```diff
- name: multiple host
uses: appleboy/ssh-action@v1.1.0
uses: appleboy/ssh-action@v1.2.0
with:
- host: "foo.com"
+ host: "foo.com:1234,bar.com:5678"
Expand All @@ -258,7 +271,7 @@ The default value of `port` is `22`.

```diff
- name: multiple host
uses: appleboy/ssh-action@v1.1.0
uses: appleboy/ssh-action@v1.2.0
with:
host: "foo.com,bar.com"
+ sync: true
Expand All @@ -274,7 +287,7 @@ The default value of `port` is `22`.

```diff
- name: pass environment
uses: appleboy/ssh-action@v1.1.0
uses: appleboy/ssh-action@v1.2.0
+ env:
+ FOO: "BAR"
+ BAR: "FOO"
Expand All @@ -299,7 +312,7 @@ _Inside `env` object, you need to pass every environment variable as a string, p

```diff
- name: stop script if command error
uses: appleboy/ssh-action@v1.1.0
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
Expand Down Expand Up @@ -352,7 +365,7 @@ Host FooServer

```diff
- name: ssh proxy command
uses: appleboy/ssh-action@v1.1.0
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
Expand All @@ -375,7 +388,7 @@ It is not uncommon for files to leak from backups or decommissioned hardware, an

```diff
- name: ssh key passphrase
uses: appleboy/ssh-action@v1.1.0
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
Expand All @@ -401,7 +414,7 @@ Now you can adjust you config:

```diff
- name: ssh key passphrase
uses: appleboy/ssh-action@v1.1.0
uses: appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
Expand Down
Loading

0 comments on commit fbf2b78

Please sign in to comment.