DanieleO DanieleO - 3 years ago 106
Bash Question

SSH Local Script on Remote Permission Denied/Path Not found

I'm Running a master.sh file from machine A to B via SSH.

This master file call another 4 snippet .sh that has to be executed using other user.

i run the master.sh i'm currently on /pathA/pathB/master.sh

ssh machineB "bash -sh" < master.sh


master.sh call other script always located on /pathA/pathB/

system_metrics=$(su mdm -c ./snippet1.sh)


result : bash: ./snippet1.sh: Permission denied
Using full path

system_metrics=$(su mdm -c /pathA/pathB/snippet1.sh)


result : bash: no such file or directory

source ./listen_port.sh
check_port_mdm


result for that code No such file or directory

Other info :

result from ls -l on script snippet1 -rwxrwxrwx 1 mdm mdm 12152

result from ls -l on /usr/bin/ssh: -rwxrwxrwx 1 root root 690952

What can I do?

Answer Source

Ok in order to close the questions Running a sh file local script from Machine A to Remote Machine B:

  • Running an sh (Not available on the machine B) file that does not call any other snippet.sh, can be done using ssh.

  • Running an sh master (Not available on the machine B) file that calls other snippet.sh, cannot be done using ssh if the snippet.sh is not available on the Machine B.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download