Git Product home page Git Product logo

github-action-ssh's Introduction

Hi, I'm Gary! 👋

I like creating cool things with code. I'm a tech and software enthusiast specialized in building thoroughly designed web apps.

github-action-ssh's People

Contributors

akoidan avatar garygrossgarten avatar jdetaeye avatar markus-mohemian avatar uglide avatar zzzz465 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

github-action-ssh's Issues

All configured authentication methods failed

Hi,
I reinstalled my server today (I upgraded it to 22.04) and when I wanted to reconfigure an automatic "git pull" on it with github actions, I got the following error :

2022-06-17T16:01:54.5793659Z Requested labels: ubuntu-latest
2022-06-17T16:01:54.5793711Z Job defined at: mcmatthevan/mcmatthevan.github.io/.github/workflows/manual.yml@refs/heads/master
2022-06-17T16:01:54.5793848Z Waiting for a runner to pick up this job...
2022-06-17T16:01:55.5591744Z Job is waiting for a hosted runner to come online.
2022-06-17T16:02:00.1063913Z Job is about to start running on the hosted runner: Hosted Agent (hosted)
2022-06-17T16:02:03.4083596Z Current runner version: '2.293.0'
2022-06-17T16:02:03.4116779Z ##[group]Operating System
2022-06-17T16:02:03.4117874Z Ubuntu
2022-06-17T16:02:03.4118907Z 20.04.4
2022-06-17T16:02:03.4119951Z LTS
2022-06-17T16:02:03.4120971Z ##[endgroup]
2022-06-17T16:02:03.4121914Z ##[group]Virtual Environment
2022-06-17T16:02:03.4127424Z Environment: ubuntu-20.04
2022-06-17T16:02:03.4128612Z Version: 20220614.0
2022-06-17T16:02:03.4130088Z Included Software: https://github.com/actions/virtual-environments/blob/ubuntu20/20220614.0/images/linux/Ubuntu2004-Readme.md
2022-06-17T16:02:03.4131758Z Image Release: https://github.com/actions/virtual-environments/releases/tag/ubuntu20%2F20220614.0
2022-06-17T16:02:03.4133020Z ##[endgroup]
2022-06-17T16:02:03.4134065Z ##[group]Virtual Environment Provisioner
2022-06-17T16:02:03.4135125Z 1.0.0.0-main-20220531-1
2022-06-17T16:02:03.4136094Z ##[endgroup]
2022-06-17T16:02:03.4138412Z ##[group]GITHUB_TOKEN Permissions
2022-06-17T16:02:03.4139938Z Actions: write
2022-06-17T16:02:03.4141023Z Checks: write
2022-06-17T16:02:03.4142023Z Contents: write
2022-06-17T16:02:03.4143127Z Deployments: write
2022-06-17T16:02:03.4144072Z Discussions: write
2022-06-17T16:02:03.4144947Z Issues: write
2022-06-17T16:02:03.4145867Z Metadata: read
2022-06-17T16:02:03.4146759Z Packages: write
2022-06-17T16:02:03.4147677Z Pages: write
2022-06-17T16:02:03.4148545Z PullRequests: write
2022-06-17T16:02:03.4149488Z RepositoryProjects: write
2022-06-17T16:02:03.4150483Z SecurityEvents: write
2022-06-17T16:02:03.4151423Z Statuses: write
2022-06-17T16:02:03.4152386Z ##[endgroup]
2022-06-17T16:02:03.4156778Z Secret source: Actions
2022-06-17T16:02:03.4158003Z Prepare workflow directory
2022-06-17T16:02:03.5113185Z Prepare all required actions
2022-06-17T16:02:03.5324836Z Getting action download info
2022-06-17T16:02:03.7919515Z Download action repository 'garygrossgarten/github-action-ssh@release' (SHA:2b10f41b5a33808f6d24eafd253296766308b7c4)
2022-06-17T16:02:04.3231032Z ##[group]Run garygrossgarten/github-action-ssh@release
2022-06-17T16:02:04.3231979Z with:
2022-06-17T16:02:04.3232685Z   command: pull
2022-06-17T16:02:04.3233560Z   host: ***
2022-06-17T16:02:04.3234272Z   username: ubuntu
2022-06-17T16:02:04.3235060Z   passphrase: ***
2022-06-17T16:02:04.3252039Z   privateKey: ***
2022-06-17T16:02:04.3252642Z   port: 22
2022-06-17T16:02:04.3253212Z env:
2022-06-17T16:02:04.3253994Z   CI: true
2022-06-17T16:02:04.3254633Z ##[endgroup]
2022-06-17T16:02:04.6057454Z Establishing a SSH connection to ***.
2022-06-17T16:02:04.6058423Z using provided private key
2022-06-17T16:02:05.1249515Z (node:1464) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
2022-06-17T16:02:05.6940921Z ⚠️ The GitHub Action couldn't connect to ***. Error: All configured authentication methods failed
2022-06-17T16:02:05.6944016Z     at doNextAuth (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:11810:17)
2022-06-17T16:02:05.6946487Z     at tryNextAuth (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:11881:5)
2022-06-17T16:02:05.6949026Z     at SSH2Stream.onUSERAUTH_FAILURE (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:11994:5)
2022-06-17T16:02:05.6950603Z     at SSH2Stream.emit (events.js:314:20)
2022-06-17T16:02:05.6951739Z     at parsePacket (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:16890:10)
2022-06-17T16:02:05.6953308Z     at SSH2Stream.module.exports.635.SSH2Stream._transform (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:13909:13)
2022-06-17T16:02:05.6954462Z     at SSH2Stream.Transform._read (_stream_transform.js:191:10)
2022-06-17T16:02:05.6955844Z     at SSH2Stream.module.exports.635.SSH2Stream._read (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:13461:15)
2022-06-17T16:02:05.6957059Z     at SSH2Stream.Transform._write (_stream_transform.js:179:12)
2022-06-17T16:02:05.6958304Z     at doWrite (_stream_writable.js:403:12) {
2022-06-17T16:02:05.6959118Z   level: 'client-authentication'
2022-06-17T16:02:05.6960926Z }
2022-06-17T16:02:05.6961779Z ⚠️ An error happened executing command pull. Not connected
2022-06-17T16:02:05.7022204Z ##[error]All configured authentication methods failed
2022-06-17T16:02:05.7033794Z Executing command: pull
2022-06-17T16:02:05.7035802Z ##[error]Not connected
2022-06-17T16:02:05.7051325Z  1: 0xa1a640 node::Abort() [/home/runner/runners/2.293.0/externals/node12/bin/node]
2022-06-17T16:02:05.7052314Z  2: 0xa90649  [/home/runner/runners/2.293.0/externals/node12/bin/node]
2022-06-17T16:02:05.7053970Z  3: 0xc06599  [/home/runner/runners/2.293.0/externals/node12/bin/node]
2022-06-17T16:02:05.7056596Z  4: 0xc08387 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/home/runner/runners/2.293.0/externals/node12/bin/node]
2022-06-17T16:02:05.7058069Z  5: 0x140dd19  [/home/runner/runners/2.293.0/externals/node12/bin/node]
2022-06-17T16:02:06.0068014Z Cleaning up orphan processes

Here is my workflow file :

name: Command via SSH

on: push

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: pull palgania server
        uses: garygrossgarten/github-action-ssh@release
        with:
          command: pull
          host: ${{ secrets.HOST }}
          username: ubuntu
          passphrase: ${{ secrets.PASSPHRASE }}
          privateKey: ${{ secrets.PRIVATE_KEY}}
        env:
          CI: true

The RSA keys which I use work correctly, I can connect my server through them.
I don't remember any issue the first time I configured it.
I did not try password connection but I can't use it, as it's a password-less login (RSA keys only).

Cannot connect to host

I'm trying to run a script on remote machine. For some reason an action fails.

My workflow looks like this:

- name: Deploy with rsync
  run: rsync -avz ./ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/app/
  
- name: Restart app
  uses: garygrossgarten/github-action-ssh@release
  with:
    command: (cd /home/${{ secrets.SSH_USER }}/app/ && ./run.sh)
    host: ${{ secrets.SSH_HOST }}
    username: ${{ secrets.SSH_USER }}
    privateKey: ${{ secrets.SSH_PRIVATE_KEY}}
    passphrase: ''

Here is output:

img

As you can see rsync is working correctly and it was able to copy all files via SSH. However the next step github-action-ssh fails.

I'm not sure what to do here so here is an issue.

Action succeeds even when the command exits with an error code

This issue can be reproduced with a very simple action - the following succeeds when it should fail:

      - name: Success against all odds
        uses: garygrossgarten/github-action-ssh@master
        with:
          command: bash -c 'exit 1'
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USERNAME }}
          password: ${{ secrets.PASSWORD }}    

Not be authenticated by the GitHub Packages service.

I am receiving this error. I created an access token with full permission but, it didn't work too.

Do you have any suggestion? Thank you.

Error response from daemon: unauthorized: Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.

(node:3089) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues

When running SSH commands directly on my Digital Ocean instance, I can see the following in the GitHub Workflows output:

(node:3089) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

Looking at the following answer from Stack Overflow: https://stackoverflow.com/a/52257416/1421836

It looks like the following matches need changing:

➜  github-action-ssh git:(master) ack 'new Buffer\('
dist/index.js
8602:    needle = new Buffer(needle);
8613:  this._lookbehind = new Buffer(needle_len);
8637:    chunk = new Buffer(chunk, 'binary');

To one of the following:

new Buffer(number)            // Old
Buffer.alloc(number)          // New
new Buffer(string)            // Old
Buffer.from(string)           // New
new Buffer(string, encoding)  // Old
Buffer.from(string, encoding) // New
new Buffer(...arguments)      // Old
Buffer.from(...arguments)     // New

Pass secrets to SSH command

How can I pass secrets to the SSH command?
Running the following command doesn't output MY_SECRET as an environment variable.

Thanks

- name: Start container services
   uses: garygrossgarten/github-action-ssh@release
   env:
     MY_SECRET: ${{ secrets.MY_SECRET }}
   with:
     host: ${{ steps.tf_out.outputs.vm_ip }}
     username: terraform
     privateKey: ${{ secrets.TF_KEY }}
     command: |
       printenv

Task don't stop running

Hi !

Thanks for your work !!

I have I basic issue I think... with my deployment code just below. My "Git pull" task is always running and don't stop.
image

image

Don't you have an idea to solve that ?

Thx

Error: config.privateKey does not exist at given fs path

I'm getting:
Error: config.privateKey does not exist at given fs path

when I use the privateKey / passphase authenication in the following action step.

    - name: ls on gadi
      uses: garygrossgarten/github-action-ssh@release
      with:
        command: ls -a
        host: "gadi.nci.org.au"
        username: ${{ secrets.GADI_UNAME }}
        #password: ${{ secrets.GADI_PWORD }}
        privateKey: ${{ secrets.GADI_PRIVATE_KEY }}
        passphrase: ${{ secrets.GADI_PASSPHRASE }}

What does this mean?
Ideas on how I can fix it?

Note, when I use GADI_PWORD my action runs as expected.

cheers,
J

Error: Timed out while waiting for handshake

I get this log from the GitHub Action:

Establishing a SSH connection to 172.31.6.56.
⚠️ The GitHub Action couldn't connect to 172.31.6.56. Error: Timed out while waiting for handshake
at Timeout._onTimeout (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/node_modules/ssh2/lib/client.js:695:19)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7) {
level: 'client-timeout'
}
1: 0x9da7c0 node::Abort() [/home/runner/runners/2.168.0/externals/node12/bin/node]
2: 0xa4e219 [/home/runner/runners/2.168.0/externals/node12/bin/node]
3: 0xba5d59 [/home/runner/runners/2.168.0/externals/node12/bin/node]
4: 0xba7b47 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/home/runner/runners/2.168.0/externals/node12/bin/node]
5: 0x13750d9 [/home/runner/runners/2.168.0/externals/node12/bin/node]

NOTE: I can connect using this ssh command:

ssh -i ~/.ssh/private.key [email protected]

So there must be wrong between using the privateKey on this action because it works with the private key file ?

Not found command

Hi, i have a remote machine (mac mini). I have connected by ssh and try to do command docker-compose pull & docker-compose up. But gh actions return: command not found: docker-compose.

Снимок экрана 2021-06-14 в 22 32 43

But if i tried connect with iterm from my pc using ssh i saw docker-compose command.
Help me please)

Process complete successfully but package throws error

events.js:187
throw er; // Unhandled 'error' event
^

Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:201:27)
Emitted 'error' event on Client instance at:
at Socket. (D:\a_actions\garygrossgarten\github-action-ssh\release\dist\index.js:9728:10)
at Socket.emit (events.js:210:5)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: 'ECONNRESET',
code: 'ECONNRESET',
syscall: 'read',
level: 'client-socket'
}

sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper

I know this is probably not an issue with this action but can I get some help with this, I am trying to restart a service on a ubuntu 20.04 server using this ssh action but I get this error.

    - name: Run SSH command
      uses: garygrossgarten/github-action-ssh@release
      with:
        command: sudo service **** restart
        host: ${{ secrets.REMOTE_HOST }}
        username: ${{ secrets.REMOTE_USER }}
        password: ${{ secrets.REMOTE_PASSWORD }}
        tryKeyboard: true

Incorrect documentation for encrypted ssh keys

I've had some issues trying to get your action to work with an encrypted ssh key. Unless I'm mistaken, in various places your documentation shows "password" instead of "passphrase". Below is an example.

`

  • name: ls -a via OPEN SSH Private Key
    uses: ./
    with:
    command: ls -a
    host: ${{ secrets.HOST }}
    username: garygrossgarten
    password: ${{ secrets.PASSPHRASE }}
    privateKey: ${{ secrets.PRIVATE_KEY}}
    `
    I have tried to connect by setting privateKey and passphrase but I am unable to connect. Using the same credentials I was able to connect with another github-action (appleboy/scp-action) so I think the credentials should be correct.

Getting "All configured authentication methods failed" using private key (password-base is working) on a seemingly well-configured server

First of all - password base authentication is working properly.

I'm trying to run commands on a VPS using private key, I've configured SSH there like this:

cd ~/.ssh
ssh-keygen -t rsa -b 4096 -C "[email protected]" # passphrase is empty
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

Then I copied the private key to my repo secrets from this file:

cat ~/.ssh/id_rsa

The key looks like this:

-----BEGIN RSA PRIVATE KEY-----
data...
-----END RSA PRIVATE KEY-----

Here is my workflow config:

name: Deploy

on: 
  push:
    branches: master

jobs:
  deploy:
    runs-on: ubuntu-latest
    
    steps:
    - name: Updating and restarting the service on remote host
      uses: garygrossgarten/github-action-ssh@release
      with:
        host: ${{ secrets.RR_HOST }} # ip address i use to access the server with 'ssh user@ip'
        username: ${{ secrets.RR_USERNAME }} # username "[email protected]"
        privateKey: ${{ secrets.RR_PRIVATE }} # private key of my VPS ~/.ssh/id_rsa file
        command: |
          cd dc-apps/go/linksmap/
          docker-compose down
          git reset --hard
          git pull
          go get ./...
          docker-compose up -d

When I try to run the job I get this:

Run garygrossgarten/github-action-ssh@release
  with:
    host: ***
    username: ***
    privateKey: ***
    command: cd dc-apps/go/linksmap/
  docker-compose down
  git reset --hard
  git pull
  go get ./...
  docker-compose up -d
  
    port: 22
(node:2404) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Establishing a SSH connection to ***.
using provided private key
⚠️ The GitHub Action couldn't connect to ***. Error: All configured authentication methods failed
    at doNextAuth (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:11803:17)
    at tryNextAuth (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:11874:5)
    at SSH2Stream.onUSERAUTH_FAILURE (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:11987:5)
    at SSH2Stream.emit (events.js:210:5)
    at parsePacket (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:16883:10)
    at SSH2Stream.module.exports.635.SSH2Stream._transform (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:13902:13)
    at SSH2Stream.Transform._read (_stream_transform.js:189:10)
    at SSH2Stream.module.exports.635.SSH2Stream._read (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:13454:15)
    at SSH2Stream.Transform._write (_stream_transform.js:177:12)
    at doWrite (_stream_writable.js:431:12) {
  level: 'client-authentication'
}
⚠️ An error happened executing command cd dc-apps/go/linksmap/
docker-compose down
git reset --hard
git pull
go get ./...
docker-compose up -d. Not connected
Error: All configured authentication methods failed
Executing command: cd dc-apps/go/linksmap/
docker-compose down
git reset --hard
git pull
go get ./...
docker-compose up -d
Error: Not connected
 1: 0x9da7c0 node::Abort() [/home/runner/runners/2.275.1/externals/node12/bin/node]
 2: 0xa4e219  [/home/runner/runners/2.275.1/externals/node12/bin/node]
 3: 0xba5d59  [/home/runner/runners/2.275.1/externals/node12/bin/node]
 4: 0xba7b47 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/home/runner/runners/2.275.1/externals/node12/bin/node]
 5: 0x13750d9  [/home/runner/runners/2.275.1/externals/node12/bin/node]

What am I doing wrong here?

Unable to login to Google cloud VM

Run garygrossgarten/github-action-ssh@release
(node:2787) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
⚠️ The GitHub Action couldn't connect to ***. Error: All configured authentication methods failed
    at doNextAuth (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:9834:17)
    at tryNextAuth (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:9905:5)
    at SSH2Stream.onUSERAUTH_FAILURE (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:10018:5)
    at SSH2Stream.emit (events.js:210:5)
    at parsePacket (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:14914:10)
    at SSH2Stream.module.exports.635.SSH2Stream._transform (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:11933:13)
    at SSH2Stream.Transform._read (_stream_transform.js:189:10)
    at SSH2Stream.module.exports.635.SSH2Stream._read (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:11485:15)
    at SSH2Stream.Transform._write (_stream_transform.js:177:12)
    at doWrite (_stream_writable.js:431:12) {
  level: 'client-authentication'
}
⚠️ An error happened executing command ls -a. Error: Not connected
    at Client.module.exports.597.Client.exec (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:10143:11)
    at /home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:20998:20
    at new Promise (<anonymous>)
    at /home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:20997:14
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:20845:103)
    at _next (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:20847:194)
    at /home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:20847:364
    at new Promise (<anonymous>)
    at /home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:20847:97
 1: 0x9da7c0 node::Abort() [/home/runner/runners/2.263.0/externals/node12/bin/node]
 2: 0xa4e219  [/home/runner/runners/2.263.0/externals/node12/bin/node]
 3: 0xba5d59  [/home/runner/runners/2.263.0/externals/node12/bin/node]
 4: 0xba7b47 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/home/runner/runners/2.263.0/externals/node12/bin/node]
 5: 0x13750d9  [/home/runner/runners/2.263.0/externals/node12/bin/node]
Establishing a SSH connection to ***.
##[error]All configured authentication methods failed

How to fail action?

Hi, thanks for providing this action. Is there a way to fail the action based on the exit code of the commands that get executed on the remote host?

Im am running git push remotely and it fails because it cannot push as there the origin has diverged. After the command has finished the action still returns successfully and the workflow continues. I am using the @release version

Any idea?

Exit not appended correctly

When using the configuration below,

    - name: Deploy code to production
      uses: fifsky/ssh-action@master
      with:
        command: ls
        host: ${{ secrets.HOSTS }}
        key: ${{ secrets.PRIVATE_KEY }}
        port: ${{ secrets.PORT_NUMBER }}
        user: ${{ secrets.USERNAME }}

this action ran the command "ls exit" on the server, which resulted in the below output.

ls exit
Pseudo-terminal will not be allocated because stdin is not a terminal.
Start Run Command
load pubkey "/github/home/.ssh/deploy_key": invalid format
ls: cannot access exit: No such file or directory

The documentation does not mention that the exit command will be appended to the existing commands. As a result, it is not running the command that it should be. Based on the errors received, I had to modify my command to be

ls &&

in order for the action to complete successfully.

How to run docker commands with env mentioned in the workflow?

Run garygrossgarten/github-action-ssh@release
Establishing a SSH connection to ***.
using provided private key
(node:1514) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
🤝 Connected to ***.
Executing command: echo $DOCKER_TOKEN | docker login ghcr.io -u $USERNAME --password-stdin
docker pull $REGISTRY:$IMAGE_NAME
docker run -p 3000:3000 $REGISTRY:$IMAGE_NAME
Error: Cannot perform an interactive login from a non TTY device

invalid reference format

docker: invalid reference format.
See 'docker run --help'.

⚠️ An error happened executing command echo $DOCKER_TOKEN | docker login ghcr.io -u $USERNAME --password-stdin
docker pull $REGISTRY:$IMAGE_NAME
docker run -p 3000:3000 $REGISTRY:$IMAGE_NAME. Command exited with code 125
Error: Command exited with code 125
 1: 0xa1a640 node::Abort() [/home/runner/runners/2.296.0/externals/node12/bin/node]
 2: 0xa90649  [/home/runner/runners/2.296.0/externals/node12/bin/node]
 3: 0xc06599  [/home/runner/runners/2.296.0/externals/node12/bin/node]
 4: 0xc08387 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/home/runner/runners/2.296.0/externals/node12/bin/node]
 5: 0x140dd19  [/home/runner/runners/2.296.0/externals/node12/bin/node]

I'm getting the above issue when I'm using the env variables mentioned in the workflow. And here is my workflow

# This workflow will do a clean installation of node dependencies, cache/restore them, 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:
  pull_request:
    branches: ['main']

env:
  REGISTRY: 'ghcr.io/testing/api-gateway'
  IMAGE_NAME: ${{ format('{0}-{1}', github.event.repository.name, github.sha) }}
  USERNAME: ${{ secrets.USERNAME }}
  DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}

jobs:
  build:
    runs-on: ubuntu-latest

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

    steps:
      - uses: actions/checkout@v3

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          cache: 'npm'
      - run: npm install
      - run: npm run build

      - name: Build & Push docker
        run: docker build -t $REGISTRY:$IMAGE_NAME .

      - name: Login to github package repository
        run: echo $DOCKER_TOKEN | docker login ghcr.io -u $USERNAME --password-stdin

      - name: Push docker image
        run: docker push $REGISTRY:$IMAGE_NAME

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

    steps:
      - name: Deploy to Digital Ocean droplet via SSH action
        uses: garygrossgarten/github-action-ssh@release
        with:
          host: ${{ secrets.DO_HOST }}
          username: ${{ secrets.DO_USER }}
          privateKey: ${{ secrets.DO_KEY }}
          passphrase: ${{ secrets.DO_PASSPHRASE }}
          command: |
            echo $DOCKER_TOKEN | docker login ghcr.io -u $USERNAME --password-stdin
            docker pull $REGISTRY:$IMAGE_NAME
            docker run -p 3000:3000 $REGISTRY:$IMAGE_NAME

What is the correct way to use these variables here?

Update to node20

I am getting a deprecation message about node 16:

Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: garygrossgarten/github-action-ssh@release. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.

I am not sure what exactly deprecated means in this context. Potentially in the future, this action will stop working on normal runners?

I see that this action hasn't been updated in a while, but it works great for me. Please consider updating the action for this.

ip or ifconfig not found

Hi!

I have some GitHub Actions workflow file - this is a part of it:

      - name: Deploy via SSH - run app
        uses: garygrossgarten/github-action-ssh@release
        with:
          command: |
            HOST=$(hostname --ip-address)
            HOST2=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')
            HOST3=$(ifconfig docker0 | grep 'inet' | cut -d: -f2 | awk '{print $2}')
            echo HOST=$HOST
            echo HOST2=$HOST2
            echo HOST3=$HOST3

            cd ${{ env.DEPLOY_DIR }}
            sed -i -E 's/SERVICE_AUTH_IMAGE=.*/SERVICE_AUTH_IMAGE='${{ env.VERSION }}'/g' .env
            sed -i -E 's/HOST_IP/'"$HOST"'/g' docker-compose.yml
            echo ${{ secrets.PACKAGES_READ_TOKEN }} | docker login ${{ env.DOCKER_REGISTRY_HOST }} -u ${{ secrets.DOCKER_LOGIN_USERNAME }} --password-stdin
            docker-compose pull
            docker-compose down
            docker-compose up -d
          host: ${{ secrets.DEPLOY_HOST }}
          port: ${{ secrets.DEPLOY_PORT }}
          username: ${{ secrets.DEPLOY_USER }}
          privateKey: ${{ secrets.DEPLOY_PRIVATE_KEY}}

Purpose of this code is deploy docker container to remote host with help of docker-compose.yml. But I need an IP address of docker0 network from linux-host. On host I can use this commands as fine:

  • hostname --ip-address
  • ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+'
  • ifconfig docker0 | grep 'inet' | cut -d: -f2 | awk '{print $2}'

But when I'm trying use this commands in workflow file I'm get an error for 2nd and 3rd commands:

ip command not found
ifconfig command not found

image

Tell me, please, how can I use the ip or ifconfig commands with this GitHub Action?

P.S. Thank you for this action - it works cool for me )

Bash Failure

Hello,

I have been using your action for a while, but recently I'm receiving the following error even though the bash script executes successfully.

    at SSH.<anonymous> (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:90:27)
    at Generator.next (<anonymous>)
    at fulfilled (/home/runner/work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:17:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

This used to work fine with no changes to my bash script.

ENAMETOOLONG: name too long, open '***'

I'm trying to run a script on remote machine. For some reason an action fails.

deploy job

deploy:
    runs-on: ubuntu-latest

    needs: build
    if: github.ref == 'refs/heads/ci-1'
    steps:
    - name: Deploy to Server
      uses: garygrossgarten/github-action-ssh@release
      with:
        command: ls -a
        host: ${{ secrets.REMOTE_HOST }}
        username: ${{ secrets.REMOTE_USER }}
        privateKey : ${{ secrets.SSH_PRIVATE_KEY}}

I set my secrets as you can see
2

I got this message
1

It seems my hostname is too long but it's the good one. I tried to connect with command line ssh @, it work's well. I try to connect to ionos host via github action

Multiple commands

I have checked closed issue Multiple discussing execute multiple commands by break line but seems like it doesn't work for me

- name: connect to ssh shoutout
        uses: garygrossgarten/[email protected]
        with:
          host: ${{ matrix.server }}
          username: ${{ matrix.user }}
          privateKey: ${{ secrets.KEY}}
          command: | 
            echo "Testing"
            echo "DD"
            ipconfig

it only returns "Testing"

am i doing something wrong here? help plz

Multiple

Its possible to run multiple command in one action ?

Error: config.privateKey does not exist at given fs path

New version is not working. (I was able to do this 5 hours ago)

Here's my config:

- name: deploy using SSH
      uses: garygrossgarten/github-action-ssh@release
      id: remote
      with:
        host: ${{ secrets.HOST }}
        username: ${{ secrets.USERNAME }}
        password: ${{ secrets.PASSWORD }}
        port: ${{ secrets.PORT }}
        command: |
          echo test

And here's the log.

Establishing a SSH connection to ***.
⚠️ The GitHub Action couldn't connect to ***. AssertionError [ERR_ASSERTION]: config.privateKey does not exist at given fs path
at new AssertionError (internal/assert/assertion_error.js:418:11)
at NodeSSH.connect (/home/runner/_work/_actions/garygrossgarten/github-action-ssh/release/dist/index.js:10101:31) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: undefined,
expected: undefined,
operator: undefined
}
Error: config.privateKey does not exist at given fs path

I have seen that there are a few updates (0.6.0 & 0.6.1), so maybe something breaks. Haven't check any code yet; just try to provide some information first.

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.