permission denied with yapf in ssh script because of make

235 Views Asked by At

I have this strange error : i have a makefile with a format target that runs yapf -ir -vv --style pep8 .

When I ssh log as user into my debian 11 server and run make format it works. When i run sudo make format i get the error

yapf -ir -vv --style pep8 .
make: yapf: No such file or directory
make: *** [makefile:5: format] Error 127

When i run a ssh script from my local machine that logs to the server and runs with the line make format, i get the following error :

yapf -ir -vv --style pep8 .
make: yapf: Permission denied
make: *** [makefile:5: format] Error 127

I also get similar output for linting:

/bin/sh: 1: pylint: Permission denied
make: *** [makefile:7: lint] Error 127

I've tried to change the owner with chown to my user, i've tried to make read and write permissions to user, group and other and it's the same...so i suspect it's a sudo thing but i'm not sure.

The user belongs to sudo group but i'm confused why the script doesnt work and it works manually...

The script is like this :

ssh -p 4444 -i /mykey user@ip << 'ENDSSH'
    echo 'deploying zabbix'
    cd /zabbix && docker-compose up -d
    echo 'zabbix deployed'
    echo 'copying zabbix module to container'
    sudo mkdir -p /var/lib/zabbix/modules/dockermodule
    docker cp /zabbix/zabbix_module_docker.so zabbixserver:/var/lib/zabbix/modules/dockermodule
    echo 'copied zabbix module to container done'
    echo 'extracting tar file'
    sudo rm -rf /app/* && sudo tar -xf /tmp/project.tar -C /
    sudo chown -R user /app
    sudo chmod -R u=rwx /app
    echo 'tar file extracted'       
    echo 'going into app folder'    
    cd /app
    echo 'getting rid of hidden macos files'
    sudo find . -type f -name '._*' -delete 
    echo 'hidden macos files deleted'
    echo 'running install'  
    make install
    echo 'install done'
    echo 'running format'
    make format
    echo 'format done'
    echo 'running lint'
    make lint
    echo 'lint done'
    echo 'running test'
    make test
    echo 'test done'
    #echo 'running vulnerability check'
    #trivy fs --security-checks vuln --severity HIGH,CRITICAL / > security_check.txt
    #echo 'vuln check done'
    echo 'running docker build & run'
    make docker 
    echo 'docker built and running'     
ENDSSH

the make commands are :

make format:
    yapf -ir -vv --style pep8 .
make lint:
    cd ..; pylint app --verbose --disable=R,C -sy

The commands are not failing when i replave make format or make lint with the commands they run in my script...

0

There are 0 best solutions below