Make sure that your key algorithm of choice is supported. On Ubuntu 20.04 or later you must explicitly allow the use of the ssh-rsa algorithm. Add the following line to your OpenSSH daemon file (which is either `/etc/ssh/sshd_config` or a drop-in file under
`/etc/ssh/sshd_config.d/`):
```bash
CASignatureAlgorithms +ssh-rsa
```
Alternatively, `ed25519` keys are accepted by default in OpenSSH. You could use this instead of rsa if needed:
```bash
ssh-keygen -t ed25519 -a 200 -C "your_email@example.com"
```
### Example
Executing remote ssh commands using password.
#### Executing remote ssh commands using password
```yaml
- name:executing remote ssh commands using password
uses: appleboy/ssh-action@master
uses:appleboy/ssh-action@v0.1.6
with:
host:${{ secrets.HOST }}
username:${{ secrets.USERNAME }}
@@ -118,11 +199,11 @@ Executing remote ssh commands using password.
script:whoami
```
Using private key
#### Using private key
```yaml
- name:executing remote ssh commands using ssh key
uses: appleboy/ssh-action@master
uses:appleboy/ssh-action@v0.1.6
with:
host:${{ secrets.HOST }}
username:${{ secrets.USERNAME }}
@@ -131,11 +212,11 @@ Using private key
script:whoami
```
Multiple Commands
#### Multiple Commands
```yaml
- name:multiple command
uses: appleboy/ssh-action@master
uses:appleboy/ssh-action@v0.1.6
with:
host:${{ secrets.HOST }}
username:${{ secrets.USERNAME }}
@@ -148,11 +229,11 @@ Multiple Commands

Multiple Hosts
#### Multiple Hosts
```diff
- name: multiple host
uses: appleboy/ssh-action@master
uses: appleboy/ssh-action@v0.1.6
with:
- host: "foo.com"
+ host: "foo.com,bar.com"
@@ -164,11 +245,11 @@ Multiple Hosts
ls -al
```
Multiple Hosts with differebt port
#### Multiple hosts with different port
```diff
- name: multiple host
uses: appleboy/ssh-action@master
uses: appleboy/ssh-action@v0.1.6
with:
- host: "foo.com"
+ host: "foo.com:1234,bar.com:5678"
@@ -179,11 +260,11 @@ Multiple Hosts with differebt port
ls -al
```
Synchronous execution on multiple hosts
#### Synchronous execution on multiple hosts
```diff
- name: multiple host
uses: appleboy/ssh-action@master
uses: appleboy/ssh-action@v0.1.6
with:
host: "foo.com,bar.com"
+ sync: true
@@ -195,11 +276,11 @@ Synchronous execution on multiple hosts
ls -al
```
Pass environment variable to shell script
#### Pass environment variable to shell script
```diff
- name: pass environment
uses: appleboy/ssh-action@master
uses: appleboy/ssh-action@v0.1.6
+ env:
+ FOO: "BAR"
+ BAR: "FOO"
@@ -209,7 +290,7 @@ Pass environment variable to shell script
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
+ envs: FOO,BAR
+ envs: FOO,BAR,SHA
script: |
echo "I am $FOO"
echo "I am $BAR"
@@ -218,11 +299,13 @@ Pass environment variable to shell script
_Inside `env` object, you need to pass every environment variable as a string, passing `Integer` data type or any other may output unexpected results._
Stop script after first failure. ex: missing `abc` folder
#### Stop script after first failure
> ex: missing `abc` folder
```diff
- name: stop script if command error
uses: appleboy/ssh-action@master
uses: appleboy/ssh-action@v0.1.6
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
@@ -247,7 +330,7 @@ err: mkdir: cannot create directory ‘abc/def’: No such file or directory
##[error]Docker run failed with exit code 1
```
How to connect remote server using `ProxyCommand`?
#### How to connect remote server using `ProxyCommand`?
```bash
+--------+ +----------+ +-----------+
@@ -271,11 +354,11 @@ Host FooServer
ProxyCommand ssh -q -W %h:%p Jumphost
```
How to convert to YAML format of GitHubActions.
#### How to convert to YAML format of GitHubActions
```diff
- name: ssh proxy command
uses: appleboy/ssh-action@master
uses: appleboy/ssh-action@v0.1.6
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
@@ -290,11 +373,15 @@ How to convert to YAML format of GitHubActions.
ls -al
```
Protecting a Private Key. The purpose of the passphrase is usually to encrypt the private key. This makes the key file by itself useless to an attacker. It is not uncommon for files to leak from backups or decommissioned hardware, and hackers commonly exfiltrate files from compromised systems.
#### Protecting a Private Key
The purpose of the passphrase is usually to encrypt the private key.
This makes the key file by itself useless to an attacker.
It is not uncommon for files to leak from backups or decommissioned hardware, and hackers commonly exfiltrate files from compromised systems.
```diff
- name: ssh key passphrase
uses: appleboy/ssh-action@master
uses: appleboy/ssh-action@v0.1.6
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
@@ -305,3 +392,37 @@ Protecting a Private Key. The purpose of the passphrase is usually to encrypt th
whoami
ls -al
```
#### Using host fingerprint verification
Setting up SSH host fingerprint verification can help to prevent Person-in-the-Middle attacks. Before setting this up, run the command below to get your SSH host fingerprint. Remember to replace `ed25519` with your appropriate key type (`rsa`, `dsa`, etc.) that your server is using and `example.com` with your host.
In modern OpenSSH releases, the _default_ key types to be fetched are `rsa` (since version 5.1), `ecdsa` (since version 6.0), and `ed25519` (since version 6.7).
We would love for you to contribute to `appleboy/ssh-action`, pull requests are welcome!
## License
The scripts and documentation in this project are released under the [MIT License](LICENSE)
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.