SFTP-Deploy-Action icon indicating copy to clipboard operation
SFTP-Deploy-Action copied to clipboard

sftp_only and delete_remote_files not working together

Open SimonIT opened this issue 2 years ago • 3 comments

SimonIT avatar Jul 01 '23 11:07 SimonIT

Is it possible that your server only accepting sftp connection? From what I see here, deleting remote files requires ssh access.

https://github.com/wlixcc/SFTP-Deploy-Action/blob/master/entrypoint.sh#L47-L58

# delete remote files if needed
if test $9 == "true";then
  echo 'Start delete remote files'
  ssh -o StrictHostKeyChecking=no -p $3 -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2 rm -rf $6
fi


if test $7 = "true"; then
  echo "Connection via sftp protocol only, skip the command to create a directory"
else
  echo 'Create directory if needed'
  ssh -o StrictHostKeyChecking=no -p $3 -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2 mkdir -p $6
fi

satriahrh avatar Jul 15 '23 04:07 satriahrh

Yes, that's exactly why I opened this issue

SimonIT avatar Jul 15 '23 10:07 SimonIT

I have the same problem. I only have sftp access but no ssh access to the target server. Anyway, I think the issue is more severe, if delete_remote_files=true and sftp_only=true because the first command checks only if we want to delete the directory, but the second one won't be executed at all. In my opinion, the first command has to check for sftp_only as well.

mvoggenreiter avatar Nov 13 '23 14:11 mvoggenreiter