GithubHelp home page GithubHelp logo

appleboy / ssh-action Goto Github PK

View Code? Open in Web Editor NEW
4.3K 34.0 526.0 441 KB

GitHub Actions for executing remote ssh commands.

Home Page: https://github.com/marketplace/actions/ssh-remote-commands

License: MIT License

Dockerfile 5.98% Shell 94.02%
github-actions ssh ssh-client

ssh-action's People

Contributors

a-maccormack avatar actionbrk avatar akleandrov avatar appleboy avatar danieldobos1985 avatar devvspaces avatar fabdelgado avatar gnawhleinad avatar h1dden-da3m0n avatar hussu010 avatar leo-schick avatar merrcury avatar mittalyashu avatar nicklasfrahm avatar seeekr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ssh-action's Issues

When I ssh to vps, I can't get vps environment variables

  1. my actions
      - name: executing remote ssh commands using password
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          password: ${{ secrets.PASSWORD }}
          port: ${{ secrets.PORT }}
          script: |
            bash ~/deploy.sh
  1. deploy.sh
#! /bin/bash
cd ~/myGo/src/x-api
git pull
go build -v
pm2 start x
  1. ERROR
======CMD======
21
bash ~/deploy.sh
22

23
======END======
24
err: From github.com:lushann/**
25
err:    dbecbb0..00deb08  master     -> origin/master
26
out: Updating dbecbb0..00deb08
27
out: Fast-forward
28
out:  .github/workflows/go.yml | 11 ++++++++++-
29
out:  1 file changed, 10 insertions(+), 1 deletion(-)
30
err: /***/deploy.sh: line 4: go: command not found
31
err: /***/deploy.sh: line 5: pm2: command not found
32
2019/12/*** 08:30:26 Process exited with status 127
33
##[error]Docker run failed with exit code 1

when I exec deploy.sh with ssh on my terminal, it's all fine. But when I use ssh-action , error will happen.

what should I do ?

Why isn't a public key required

It's neither a feature request nor a bug. I'm just curious to know why a public key in the Github secrets is not required? How just only a private key is sufficient to ssh into a remote server.

Shold `port` has a default value 22 ?

Hi,
I got an error with the latest version:

2019/09/30 08:11:32 could not parse  as int value for flag port,p: strconv.ParseInt: parsing "": invalid syntax

Is it better to give port a default value?

Executing remote ssh commands is failing

- name: Deploy to ${{ secrets.HOST }}, executing remote ssh commands using ssh key
      uses: appleboy/ssh-action@master
      with: |
        username: ${{ secrets.USERNAME }}
        host: ${{ secrets.HOST }}
        script: ~/deploy.sh
        key_path: ${{ secrets.DEPLOY_KEY }}

When GitHub action starts it fails on below error.

##[error]The template is not valid. .github/workflows/main.yml (Line: 28, Col: 13): Unexpected value 'username: ***

Ignore script output

Hey,

I am currently facing the issue that the output of some of my scripts is getting classified as "error" which causes the github action to get the fail status:

Unbenannt

For me it would be very helpful to get an flag for each script line which allows to ignore the output. :-)

Legacy algorithm support

I got the following message when trying to ssh a BlueHost server:

2020/05/23 13:43:07 ssh: handshake failed: ssh: no common algorithm for key exchange; client offered: [[email protected] ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521 diffie-hellman-group14-sha1], server offered: [diffie-hellman-group-exchange-sha256]

Even when I try [email protected].

SSH Key Passphrase

Hello,

How do I provide an SSH key passphrase? When adding both a key and password it throws an error that I cannot have both.

tar: empty archive - Docker run failed with exit code 1

I could not understand which variable could be wrong?
We maybe need a better error message?

  with:
    host: ***
    username: ***
    key: ***
    port: 22
    source: ~/exportServer/backup.sql
    target: ~/backup.sql
    timeout: 30s
    command_timeout: 10m
    strip_components: 0
    overwrite: false
/usr/bin/docker run --name ee6078d19cbf8da4672854dd240c06f80c0_3b33ce --label 671ee6 --workdir /github/workspace --rm -e INPUT_HOST -e INPUT_USERNAME -e INPUT_KEY -e INPUT_PORT -e INPUT_SOURCE -e INPUT_TARGET -e INPUT_PASSWORD -e INPUT_TIMEOUT -e INPUT_COMMAND_TIMEOUT -e INPUT_KEY_PATH -e INPUT_RM -e INPUT_STRIP_COMPONENTS -e INPUT_OVERWRITE -e INPUT_TAR_TMP_PATH -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/nacho/nacho":"/github/workspace" 671ee6:078d19cbf8da4672854dd240c06f80c0
tar: empty archive
tar all files into /tmp/640661935/xqJM6FeoeL.tar
exit status 1
##[error]Docker run failed with exit code 1

with colors:
image

Error: dial tcp PORT: connect: connection refused

When trying to run a command that is starting a node process, it throws this error

Run appleboy/ssh-action@master
  with:
    port: 22
    sync: false
    timeout: 30s
    command_timeout: 10m
    proxy_port: 22
    proxy_timeout: 30s
    script_stop: false
    debug: false
  env:
    USERNAME: ***
    HOST: ***
    KEY: ***
  
    SCRIPT: cd *** && node main.js
    PORT: 3000
/usr/bin/docker run --name e87b522ab8732cb714423cb9b4eda618507167_99b156 --label e87b52 --workdir /github/workspace --rm -e USERNAME -e HOST -e KEY -e SCRIPT -e PORT -e INPUT_HOST -e INPUT_PORT -e INPUT_PASSPHRASE -e INPUT_USERNAME -e INPUT_PASSWORD -e INPUT_SYNC -e INPUT_TIMEOUT -e INPUT_COMMAND_TIMEOUT -e INPUT_KEY -e INPUT_KEY_PATH -e INPUT_PROXY_HOST -e INPUT_PROXY_PORT -e INPUT_PROXY_USERNAME -e INPUT_PROXY_PASSWORD -e INPUT_PROXY_PASSPHRASE -e INPUT_PROXY_TIMEOUT -e INPUT_PROXY_KEY -e INPUT_PROXY_KEY_PATH -e INPUT_SCRIPT -e INPUT_SCRIPT_STOP -e INPUT_ENVS -e INPUT_DEBUG -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/ests-iot-server/ests-iot-server":"/github/workspace" e87b52:2ab8732cb714423cb9b4eda618507167
======CMD======
cd *** && node main.js

======END======
2020/03/26 23:45:18 dial tcp ***:3000: connect: connection refused

No common Algorithm

While connecting to a ssh server I get the following message? any conf or server side config/tweak to be made?

Regards

2020/02/28 00:38:25 ssh: handshake failed: ssh: no common algorithm for key exchange; client offered: [[email protected] ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521 diffie-hellman-group14-sha1], server offered: [diffie-hellman-group-exchange-sha256]

Unable to run deployment server specific commands

I am trying to use commands like "npm install", "pm2 restart",
but action fails:

err: bash: line 3: npm: command not found
err: bash: line 4: pm2: command not found

I am using nvm on the server, and thought that it might be the path resolution issue.
However, even using the absolute path, hardcoded, did not help:

err: /usr/bin/env: ‘node’: No such file or directory
err: /usr/bin/env: ‘node’: No such file or directory

SSH through multiple hosts?

Hey,

+--------+       +-----------+      +-----------+      +-----------+
| Laptop | <-->  | Jumphost1 | <--> | Jumphost2 | <--> | FooServer |
+--------+       +-----------+      +-----------+      +-----------+

In my ~/.ssh/config. There are some hosts:

Host Jumphost1
    HostName Jumphost
    User ubuntu
    IdentityFile ~/.ssh/keys/jump_host1.pem

Host Jumphost2
    HostName FooServer
    User ubuntu
    ProxyCommand ssh -q -W %h:%p Jumphost1

Host FooServer
    HostName FooServer
    User ubuntu
    ProxyCommand ssh -q -W %h:%p Jumphost2

How to do this in yaml?
Thanks

Pass environment variable to shell script not working

Hi, I saw your example in the README of how to pass environment variable to shell script. However, in the example the variables are just strings. I wanted to pass something like:

PRNumber: ${{ github.event.pull_request.number }}

But this doesn't seem to work. The output will be empty. Do you have an example of how to pass this correctly?

ssh-action can't log in but scp-action can

I'm trying to use this action along with your scp-action to update some files on my server and then execute a command, and it looks like the scp-action command works but the ssh-action doesn't.

Here's the log for the run.

The scp-action completes successfully, printing out Successfully executed transfer data to all host and I can see that the files appear on my host. The ssh-action errors out with Error: can't connect without a private SSH key or password (even though the exact same ssh key worked for scp-action).

I'm providing the same host, key, and username to both actions, so I'm not sure why the ssh-action is erroring at login out the way it is. I would figure that if scp-action were able to connect to my server, then ssh-action would be able to as well.

The relevant config from my yaml file:

    - name: Upload to EC2
      uses: appleboy/scp-action@master
      with:
        host: ${{ secrets.EC2_IP }}
        key: ${{ secrets.EC2_KEY }}
        username: ec2-user
        source: "*"
        target: "server"
        rm: true
    - name: Deploy to EC2
      uses: appleboy/ssh-action@master
      env:
        host: ${{ secrets.EC2_IP }}
        key: ${{ secrets.EC2_KEY }}
        username: ec2-user
        script: echo hi

secrets.EC2_KEY is a PEM key, i.e.

kevin@raikou:~$ cat ~/Desktop/game-server.pem
-----BEGIN RSA PRIVATE KEY-----
MIIE******************
**********************
*******************2U=
-----END RSA PRIVATE KEY-----

Debug is not giving debug information

Hey,

I am actually facing the issue that my ssh connection is not going through successfully.

2020/02/27 13:04:57 ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

In order to check what is going wrong, I've set debug to true, but sadly I am not getting any detailed information:

2020-02-27T13:04:41.8061247Z ##[section]Starting: Request a runner to run this job 2020-02-27T13:04:42.6211291Z Requesting a hosted runner in current repository's account/organization with labels: 'ubuntu-latest', require runner match: True 2020-02-27T13:04:42.7111306Z Labels matched hosted runners has been found, waiting for one of them get assigned for this job. 2020-02-27T13:04:42.7711318Z ##[section]Finishing: Request a runner to run this job 2020-02-27T13:04:50.4638701Z Current runner version: '2.165.2' 2020-02-27T13:04:50.4640809Z Prepare workflow directory 2020-02-27T13:04:50.4835105Z Prepare all required actions 2020-02-27T13:04:50.4850769Z Download action repository 'appleboy/ssh-action@master' 2020-02-27T13:04:51.7923998Z Build container for action use: '/home/runner/work/_actions/appleboy/ssh-action/master/Dockerfile'. 2020-02-27T13:04:51.7989413Z ##[command]/usr/bin/docker build -t e87b52:327d6d8367a346f88965e4af500fff29 "/home/runner/work/_actions/appleboy/ssh-action/master" 2020-02-27T13:04:52.7528007Z Sending build context to Docker daemon 290.3kB 2020-02-27T13:04:52.7528791Z 2020-02-27T13:04:52.7539746Z Step 1/4 : FROM appleboy/drone-ssh:1.5.5-linux-amd64 2020-02-27T13:04:52.7541276Z 1.5.5-linux-amd64: Pulling from appleboy/drone-ssh 2020-02-27T13:04:52.7542671Z 63bc94deeb28: Pulling fs layer 2020-02-27T13:04:52.7544297Z ac44f5a8c67b: Pulling fs layer 2020-02-27T13:04:52.7546119Z 276b00fdab51: Pulling fs layer 2020-02-27T13:04:52.7547452Z f6a39918766c: Pulling fs layer 2020-02-27T13:04:52.7553569Z f6a39918766c: Waiting 2020-02-27T13:04:52.7555018Z 276b00fdab51: Verifying Checksum 2020-02-27T13:04:52.7556364Z 276b00fdab51: Download complete 2020-02-27T13:04:52.7557708Z ac44f5a8c67b: Verifying Checksum 2020-02-27T13:04:52.7559035Z ac44f5a8c67b: Download complete 2020-02-27T13:04:52.7560648Z 63bc94deeb28: Download complete 2020-02-27T13:04:52.8562406Z 63bc94deeb28: Pull complete 2020-02-27T13:04:52.8863395Z f6a39918766c: Verifying Checksum 2020-02-27T13:04:52.8864803Z f6a39918766c: Download complete 2020-02-27T13:04:52.9475861Z ac44f5a8c67b: Pull complete 2020-02-27T13:04:52.9916911Z 276b00fdab51: Pull complete 2020-02-27T13:04:53.1027166Z f6a39918766c: Pull complete 2020-02-27T13:04:53.1061337Z Digest: sha256:e5a96d1c06e159a963574b40b3591de499cf3c03f0aa92952998eece3c33af4d 2020-02-27T13:04:53.1083633Z Status: Downloaded newer image for appleboy/drone-ssh:1.5.5-linux-amd64 2020-02-27T13:04:53.1097717Z ---> 5e8a678bcca9 2020-02-27T13:04:53.1123164Z Step 2/4 : ADD entrypoint.sh /entrypoint.sh 2020-02-27T13:04:54.8237623Z ---> c7059f35f89d 2020-02-27T13:04:54.8239286Z Step 3/4 : RUN chmod +x /entrypoint.sh 2020-02-27T13:04:54.8464403Z ---> Running in 478f464277bb 2020-02-27T13:04:56.0115281Z Removing intermediate container 478f464277bb 2020-02-27T13:04:56.0138276Z ---> 9095f2c8ac72 2020-02-27T13:04:56.0139677Z Step 4/4 : ENTRYPOINT ["/entrypoint.sh"] 2020-02-27T13:04:56.0302861Z ---> Running in d6e2ee2ac73f 2020-02-27T13:04:57.0092648Z Removing intermediate container d6e2ee2ac73f 2020-02-27T13:04:57.0093893Z ---> bb5608224b99 2020-02-27T13:04:57.0140531Z Successfully built bb5608224b99 2020-02-27T13:04:57.0259752Z Successfully tagged e87b52:327d6d8367a346f88965e4af500fff29 2020-02-27T13:04:57.0704672Z ##[group]Run appleboy/ssh-action@master 2020-02-27T13:04:57.0705693Z with: 2020-02-27T13:04:57.0707126Z host: *** 2020-02-27T13:04:57.0707858Z username: ec2-user 2020-02-27T13:04:57.0716522Z key: *** 2020-02-27T13:04:57.0717252Z script: whoami 2020-02-27T13:04:57.0718018Z debug: true 2020-02-27T13:04:57.0718752Z port: 22 2020-02-27T13:04:57.0719490Z sync: false 2020-02-27T13:04:57.0720225Z timeout: 30s 2020-02-27T13:04:57.0720955Z command_timeout: 10m 2020-02-27T13:04:57.0721683Z proxy_port: 22 2020-02-27T13:04:57.0722426Z proxy_timeout: 30s 2020-02-27T13:04:57.0723144Z script_stop: false 2020-02-27T13:04:57.0723864Z ##[endgroup] 2020-02-27T13:04:57.0786859Z ##[command]/usr/bin/docker run --name e87b52327d6d8367a346f88965e4af500fff29_8744d9 --label e87b52 --workdir /github/workspace --rm -e INPUT_HOST -e INPUT_USERNAME -e INPUT_KEY -e INPUT_SCRIPT -e INPUT_DEBUG -e INPUT_PORT -e INPUT_PASSPHRASE -e INPUT_PASSWORD -e INPUT_SYNC -e INPUT_TIMEOUT -e INPUT_COMMAND_TIMEOUT -e INPUT_KEY_PATH -e INPUT_PROXY_HOST -e INPUT_PROXY_PORT -e INPUT_PROXY_USERNAME -e INPUT_PROXY_PASSWORD -e INPUT_PROXY_PASSPHRASE -e INPUT_PROXY_TIMEOUT -e INPUT_PROXY_KEY -e INPUT_PROXY_KEY_PATH -e INPUT_SCRIPT_STOP -e INPUT_ENVS -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/Content-Sync-Integration-Tests-Drupal/Content-Sync-Integration-Tests-Drupal":"/github/workspace" e87b52:327d6d8367a346f88965e4af500fff29 2020-02-27T13:04:57.3839526Z ======CMD====== 2020-02-27T13:04:57.3840675Z whoami 2020-02-27T13:04:57.3841563Z ======END====== 2020-02-27T13:04:57.3842449Z ======ENV====== 2020-02-27T13:04:57.3842962Z 2020-02-27T13:04:57.3843836Z ======END====== 2020-02-27T13:04:57.9609604Z 2020/02/27 13:04:57 ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain 2020-02-27T13:04:58.1488035Z Cleaning up orphan processes

I was hoping to get an overview of which commands have been executed in detail, like for example:

ssh ...... -v

Any chance to get that?

Executing remote ssh commands failing

- name: Deploy to ${{ secrets.HOST }}, executing remote ssh commands using ssh key
      uses: appleboy/ssh-action@master
      with: |
        username: ${{ secrets.USERNAME }}
        host: ${{ secrets.HOST }}
        script: ~/deploy.sh
        key_path: ${{ secrets.DEPLOY_KEY }}

When GitHub action starts it fails on below error.

##[error]The template is not valid. .github/workflows/main.yml (Line: 28, Col: 13): Unexpected value 'username: ***

i/o timeout

i can't connect to my server. having dial tcp ***:22: i/o timeout error

ssh: handshake failed: EOF

Hi,

I tried to configure this action with a repo having the following configuration:

     - name: executing remote ssh commands
       uses: appleboy/ssh-action@master
       with:
         host: ${{ secrets.SERVER_SSH_IP }}
         username: ${{ secrets.SERVER_SSH_USER }}
         key: ${{ secrets.SERVER_SSH_KEY }}
         debug: true

I have an error, but I don't know how to fix it. I use an ssh key and I tried with other actions like this one and others which use ssh connection and it works.

 executing remote ssh commands
8s
##[error]Docker run failed with exit code 1
Run appleboy/ssh-action@master
/usr/bin/docker run --name dfb4559ed09dcb24dc8b6a0337ed1f1d846_7656cb --label 488dfb --workdir /github/workspace --rm -e INPUT_HOST -e INPUT_USERNAME -e INPUT_KEY -e INPUT_DEBUG -e INPUT_PORT -e INPUT_PASSPHRASE -e INPUT_PASSWORD -e INPUT_TIMEOUT -e INPUT_COMMAND_TIMEOUT -e INPUT_KEY_PATH -e INPUT_PROXY_HOST -e INPUT_PROXY_PORT -e INPUT_PROXY_USERNAME -e INPUT_PROXY_PASSWORD -e INPUT_PROXY_PASSPHRASE -e INPUT_PROXY_TIMEOUT -e INPUT_PROXY_KEY -e INPUT_PROXY_KEY_PATH -e INPUT_SCRIPT -e INPUT_SCRIPT_STOP -e INPUT_ENVS -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/my-repo/my-repo":"/github/workspace" 488dfb:4559ed09dcb24dc8b6a0337ed1f1d846
======CMD======

======END======
======ENV======

======END======
2020/01/26 12:07:04 ssh: handshake failed: EOF
##[error]Docker run failed with exit code 1

The ssh key is generated and stored in secrets, added on server in ~/.ssh/authorized_keys file.

Store artifacts

Hey,

is there a way to create artifacts while connected via ssh?

Some commands don't work

err: bash: -c: line 3: syntax error near unexpected token `('
2020/02/09 17:57:24 Process exited with status 1
err: bash: -c: line 3: `sudo rm -r /usr/dotnetapps/bugsincluded/!(*.db*)'

This is a valid linux command that removes all files and folders that don't match the pattern, it works when I run it manually on my server, but it doesn't work using this ssh-action tool.

SSH Key

I'm trying to use this action to ssh into my AWS EC2 Instance but I keep getting this error,
2019/10/01 09:51:51 ssh.ParsePrivateKey: ssh: no key found. I'm still not sure what contents do I need to add for the key in github secrets. I have the .pem private key from AWS

tag versioning

For safety reasons would be good to release versions using tags.

Currently looks that you stoped using tagging...

ForwardAgent

Is there a way to use the ForwardAgent Option with this action? So that you could use the rsa key for example for git pull.

I/O Timeout Error

It doesn't just make any other error:

`======CMD======
docker rm -f $(docker ps -aq -f name=erp-front)
docker rmi $(docker images | grep 'emiryumak/erp-front' | awk '{print $3}')
docker pull emiryumak/erp-front:latest
docker run --name erp-front -p 5000:80 --restart=always -d emiryumak/erp-front

======END======
======ENV======

======END======
2020/05/16 20:31:15 dial tcp :: i/o timeout`

I don't understand thats error. Its meaning can not connect to my server?

End Successfully even if the git command error occurs

Hello.
The ssh server is WindowsServer2016.
yaml is here.

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Deploy
      uses: appleboy/ssh-action@master
      with: 
        host: ${{ secrets.HOST}}
        username: ${{ secrets.USER }}
        port: ${{ secrets.SSH_PORT}}
        password: ${{ secrets.PASSWORD }}
        script_stop: true
        script: |
          cd ${{ secrets.DEPLOY_PATH }}&git pull origin master&iisreset /restart

Windows command doesn't seem to work if multiple lines are specified, so I wrote script command like this.

The log is below.

======CMD======
cd ***&git pull origin master&iisreset /restart

======END======

~~~~~~~~~~~~~~~
err: * branch master -> FETCH_HEAD
err: 3573750..76179a8 master -> origin/master
err: error: Your local changes to the following files would be overwritten by merge: ★here
err: config/settings.py
err: requirements.txt
err: Please commit your changes or stash them before you merge.
err: Aborting
out: Updating b032eb0..76179a8
out:
out: Attempting stop...
out: Internet services successfully stopped
out: Attempting start...
out: Internet services successfully restarted
==============================================
✅ Successfully executed commands to all host.
==============================================

I don't know if this behavior is normal or a bug.
Please advise if my configuration is wrong.

npm command not found

I have npm installed on my server, why does the 'npm command not found' error during deployment?

Timeout when execute a command

I have this workflow

name: Deploy to development environment
on:
  push:
    branches:
      - master
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Vultr remote machine
      uses: appleboy/ssh-action@master
      with:
        args: >
          --host ${{ secrets.SSH_HOST }} --user ${{ secrets.SSH_USER }} --password ${{ secrets.SSH_PASSWORD }}
          --script 'git checkout master'
          --script 'npm install'
          --script 'npm run build:prod'

I got this output:

======CMD======
git checkout master
npm install
npm run build:prod
======END======
err: Already on 'master'
out: Your branch is up-to-date with 'origin/master'.
2019/09/08 08:54:06 Error: command timeout
err: Run Command Timeout!
##[error]Docker run failed with exit code 1

How can I increase the timeout?

Using secrets within commands

Hey,

is it possible to use secrets within the commands? Like for example:

      - name: I123
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.1 }}
          username: ${{ secrets.2 }}
          key: ${{ secrets.3 }}
          proxy_host: ${{ secrets.4 }}
          proxy_username: ${{ secrets.5 }}
          proxy_key: ${{ secrets.6 }}
          script: |
            echo ${{ secrets.7 }}

Best regards
Sebastian

Environment variables don't work

My actions config:

name: remote ssh command
on: [push]
jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
    - name: executing remote ssh commands using password
      uses: appleboy/ssh-action@master
      env:
        PG_DATA_VOLUME: ${{ secrets.PG_DATA_VOLUME }}
        PG_PASSWORD: ${{ secrets.PG_PASSWORD }}
        PG_USERNAME: ${{ secrets.PG_USERNAME }}
        PG_DBNAME: ${{ secrets.PG_DBNAME }}
      with:
        host: ${{ secrets.SSH_HOST }}
        username: ${{ secrets.SSH_USERNAME }}
        key: ${{ secrets.SSH_KEY }}
        port: ${{ secrets.SSH_PORT }}
        envs: PG_DATA_VOLUME,PG_PASSWORD,PG_USERNAME,PG_DBNAME
        script: |
          env

env command outputs env vars, but it doesn't output PG_DATA_VOLUME, PG_PASSWORD, etc.
So the issue is env vars are not available in ssh session.

Running background command using `&` causes the step to halt and timeout

I am executing a command like this in the step:
python script.py &
echo Done

This causes the step to get stuck in progress after echoing Done and eventually timeout (after ~10 minutes) whereas it should be done in 10 seconds.
However, if I kill the process (python script.py) manually by SSH'ing to the server, the step completes execution successfully. How can I fix this problem and run background commands successfully?

Other variants I have tried:
nohup python script.py &
disown

Passing options to ssh

Is it possible to pass options to the ssh command?
I couldn't find it in the documentation.

For example how we pass it via ssh -o StrictHostKeyChecking=no

Unable to execute valid pm2 command

I am using the action to:

  • cd to project directory (Success)
  • pull the latest code from master on my repo (Success)
  • Restart the pm2 deployment using "pm2 restart app" (Failure)

err: bash: line 2: pm2: command not found

I'm pretty sure pm2 is working well on my server. Does the action use a sub process that doesn't have all the dependencies?

Problem with comma splitting docker parameters into several commands

You have a comma , used to separate multiple commands in a single string. This makes it impossible to run commands which have a comma in their parameters. For example, docker mount:

--mount type=volume,src=<VOLUME-NAME>,dst=<CONTAINER-PATH>

This parameter line is split at commas even though I use multiline YAML format for script. Maybe it's better to remove comma altogether and rely exclusively on YAML multiline support.

err: stdin: is not a tty

======CMD======
cd /home
git stash
git pull

======END======
err: stdin: is not a tty
out: Saved working directory and index state WIP on master: 7a904f0 chore: add apache config file
err: Permission denied (publickey).
err: fatal: Could not read from remote repository.
err:
err: Please make sure you have the correct access rights
err: and the repository exists.
2020/02/05 08:33:29 Process exited with status 1

Error: missing host server

So in case anyone, like I did, bumps into this error, it might be because you're using the version given by default by github (v0.0.2) which, I guess, didn't support the env variables correctly.
What I did was simply updating:
uses: appleboy/[email protected]
to
uses: appleboy/ssh-action@master
Though I guess using other tags will work also.
Thanks for the Action btw !

Not failing properly

Hello,

My cmd that I execute is bash /root/deploy.sh when executing the step I get:

======CMD======
*** 161818ed29a100f924cb7aaa862e297d92c457d7

======END======
err: fatal: not a git repository (or any of the parent directories): .git
err: fatal: not a git repository (or any of the parent directories): .git
err: fatal: not a git repository (or any of the parent directories): .git
err: /***/***/deploy.sh: line 9: go: command not found
err: /***/***/deploy.sh: line 12: go: command not found
==============================================
✅ Successfully executed commands to all host.
==============================================

Why is this returned as a success when the exit code is 1?

      - name: Deploy
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          key: ${{ secrets.KEY }}
          script_stop: true
          script: |
            ${{ secrets.DEPLOY_CMD }} ${{ github.sha }}

SSH Key doesn't work

tried to use ssh private key. below way. copy the key and put it into the secrets.

cat ~/.ssh/id_rsa

  deploy:
    needs: [build]
    runs-on: ubuntu-latest

    steps:
    - name: SSH and deploy node app
      uses: appleboy/[email protected]
      with:
        args: > 
          --host ${{ secrets.NODE_SERVER }} --user ${{ secrets.SSH_USER }} --ssh-key ${{ secrets.SSH_KEY }}
          --script 'whoami'  

i am getting this error

2019/09/19 12:12:55 ssh.ParsePrivateKey: ssh: no key found
2019/09/19 12:12:55 ssh: handshake failed: ssh: unable to authenticate, attempted methods [none], no supported methods remain

SSH key works from my local machine, but not with this Action.

Hi, I am having some trouble getting your action to connect to my DigitialOcean droplet.
I have tried both SSH connections via a SSH Key and a standard User/Password.

The error
handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

My config

- name: Deploy
    uses: appleboy/ssh-action@master
    with:
       host: ${{ secrets.DIGITAL_OCEAN_DROPLET_HOST }}
       username: ${{ secrets.DIGITAL_OCEAN_DROPLET_USER }}
       password: ${{ secrets.DIGITAL_OCEAN_DROPLET_PASSWORD }}
       script: whoami

Lastly, reviewing some of the resolved repo issues, I followed your advice to follow this article http://www.linuxproblem.org/art_9.html which gets you to append the public SSH key to the remote servers authorized_keys file.

Cheers,

Issues with SSH

I keep getting this issue:

2020/05/03 ***:19:30 ssh.ParsePrivateKey: no PEM block found
ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

I have this for my .yml file

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [12.x]

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: npm i
    - run: npm run build --if-present
    - run: node app.js
    - name: Executing remote ssh commands
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.HOST }}
        username: ${{ secrets.USERNAME }}
        key: ${{ secrets.KEY }}
        passphrase: ${{ secrets.PASSPHRASE }}
        port: ${{ secrets.PORT }}
        script: whoami

KEY is my private key on my server so I don't know what the issue could be.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.