You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Hey, went through the answers and tried different approaches but nothing worked.
My question is how it would be possible to run my shell/bash script in separate file (my-script.sh), which is located on ext to github action file CI.yml?
- name: Executing remote commanduses: appleboy/ssh-action@v0.1.2with:
...script: sh ./my-script.sh
In other CIs or terminal where this nice appleboy/ssh-action doesnt exist, to make it work you pass your own shell script as:
cd /var/www/html/my-project
git pull
npm install
forever restart project
But while action run on git hub, it is giving below error
err: /var/www/automation/rerun-project.sh: 3: /var/www/automation/rerun-project.sh: npm: not found
err: /var/www/automation/rerun-project.sh: 4: /var/www/automation/rerun-project.sh: forever: not found
Below first two command working perfectly fine but not sure why npm and forever not working. npm & forever command I am able to execute from putty.
Using the full path of the binary in the script worked for me. I believe the non interactive shell obtained from appleboy does not load the correct profiles.
// Example
/usr/local/go/bin/go build -o ./bin/client
/usr/bin/npm install
The full path didn't work for me, but I found a solution. I realized that if I run echo $PATH in in a normal SSH session, I get a longer $PATH compared to what I get if I run the same command with the this GH Action workflow.
Reason: interactive vs non-interactive shell see → #31 (comment)
basically, if you are running a command in a non interactive shell, like ssh-action, on many linux distros,
"/etc/bash.bashrc" file has a specific command that returns only, so some of the files didn't run and some specific commands doesn't add to path,
basically, if you are running a command in a non interactive shell, like ssh-action, on many linux distros,
"/etc/bash.bashrc" file has a specific command that returns only, so some of the files didn't run and some specific commands doesn't add to path,
# /etc/bash.bashrc
# System-wide .bashrc file for interactive bash(1) shells.
# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.
# If not running interactively, don't do anything
[ -z "$PS1" ] && return`
just comment out the line that returns early and everything should work fine, or you can use the real paths of the commands that you would like to use.
Thanks @kocyigityunus. Commenting the .bashrc line solved my issue. As my workflow runs nvm, yarn and docker scripts, that was the easiest way to handle
Reacted by Marcell Harmaci, Bo-Yi Wu and Tomsykesss
How to handle this scenario? I can't find a way to ignore the results of the kill
- name: Stop previous version on AWS EC2
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.AWS_HOST }}
username: ${{ secrets.AWS_USERNAME }}
key: ${{ secrets.AWS_SSH_KEY }}
script: pkill -f "genart" || true
======= CLI Version =======
Drone SSH version 1.8.1
2025/07/03 03:04:24 Process exited with status 143 from signal TERM
Error: Process completed with exit code 1.
Activity
appleboy commentedon Apr 30, 2020
Another approach is to put your command into the shell script file and execute
sh xxxx.sh.palashCItobuz commentedon May 7, 2020
@appleboy
The shell script is being able to run node js or npm commands. How can they be executed? Tried loading
. /etc/profilein the shell script.mittalyashu commentedon Jul 7, 2020
Any suggestions?
If we try to execute
sh ../../scripts/deploy.shwouldn't it will try running inside the server where we're trying SSH into.mojo706 commentedon Jul 7, 2020
I think it will try to execute inside the vps you're trying to ssh into. You could use
runinstead like thisI think that should work
mittalyashu commentedon Jul 8, 2020
@mojo706 It shows an error:
mojo706 commentedon Jul 8, 2020
@mittalyashu could you show me your whole discord job?
mittalyashu commentedon Jul 8, 2020
@mojo706
mojo706 commentedon Jul 8, 2020
@mittalyashu try that
mittalyashu commentedon Jul 8, 2020
Isn't it the exact same code which I have shared.
#31 (comment)
mojo706 commentedon Jul 8, 2020
Lol shit I forgot to change it. I guess I was tired, I wanted you to add
rununderusesit should work now.mittalyashu commentedon Jul 9, 2020
You mean something like this?
appleboy commentedon Jul 9, 2020
mojo706 commentedon Jul 9, 2020
you need to have the
stepskeyword @mittalyashu13 remaining items
MageshSrinivasulu commentedon Oct 10, 2022
@ShravaniRoy Thanks for the quick response. Created a separate issue for the same #189
mkosir commentedon Oct 20, 2022
Hey, went through the answers and tried different approaches but nothing worked.
My question is how it would be possible to run my shell/bash script in separate file (my-script.sh), which is located on ext to github action file CI.yml?
In other CIs or terminal where this nice appleboy/ssh-action doesnt exist, to make it work you pass your own shell script as:
marqueetest commentedon Jul 12, 2023
Here is my config
Below is my sh file
But while action run on git hub, it is giving below error
Below first two command working perfectly fine but not sure why npm and forever not working. npm & forever command I am able to execute from putty.
Jkarage commentedon Jul 21, 2023
Using the full path of the binary in the script worked for me. I believe the non interactive shell obtained from appleboy does not load the correct profiles.
// Example
/usr/local/go/bin/go build -o ./bin/client
/usr/bin/npm install
Hope using this or other tools would work.
MarcellHarmaci commentedon Sep 5, 2023
The full path didn't work for me, but I found a solution. I realized that if I run
echo $PATHin in a normal SSH session, I get a longer$PATHcompared to what I get if I run the same command with the this GH Action workflow.Reason: interactive vs non-interactive shell see → #31 (comment)
Solution for npm: #21 (comment)
General solution:
$PATHwhen the action runs$PATHdirectories to the thing you are trying to use will probably solve the issue.ondanieldev commentedon May 4, 2024
Thanks @kocyigityunus. Commenting the .bashrc line solved my issue. As my workflow runs nvm, yarn and docker scripts, that was the easiest way to handle
appleboy commentedon May 4, 2024
I will update the README to address the @kocyigityunus solution.
appleboy commentedon May 4, 2024
See the document: https://github.com/appleboy/ssh-action#command-not-found-npm-or-other-command
quilicicf commentedon Jul 12, 2024
Another solution that works (only for node global modules):
dingshaohuax commentedon Oct 13, 2024
no file
/etc/bash.bashrcin centos9ondanieldev commentedon Oct 13, 2024
Currently I do not have issues with that, but I do not use bash on my servers anymore. Instead, I use zsh.
dingshaohuax commentedon Oct 13, 2024
I have found a good solution, just add a line to your script, eg:
the /etc/profile is working for
ssh remote command user, refer to this articlecuikaipeng commentedon Dec 23, 2024
thanks!!!
it works for me
izlatkin commentedon Jul 3, 2025
How to handle this scenario? I can't find a way to ignore the results of the kill
- name: Stop previous version on AWS EC2
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.AWS_HOST }}
username: ${{ secrets.AWS_USERNAME }}
key: ${{ secrets.AWS_SSH_KEY }}
script: pkill -f "genart" || true
======= CLI Version =======
Drone SSH version 1.8.1
2025/07/03 03:04:24 Process exited with status 143 from signal TERM
Error: Process completed with exit code 1.