1

I have 2 users on a remote machine (let's call them user1 and user2, with both being in the common group upload).

I want to be able to upload/override a file via scp, from different machines. Whereas machine1 uploads with user1, and machine2 uploads with user2.

machine1: scp -p myfile.txt user1@<ip>:/opt/test/

machine2: scp -p myfile.txt user2@<ip>:/opt/test/

Problem for user2: set mode: Operation not permitted. This seems to be caused by the -p flag (preserve timestamps). As when I remove the parameter, everything works fine.

Question: how can I still preserve timestamp if I'm not the owner of the remote file that should be overridden?

1 Answer 1

0

If you are not able to change the permissions after uploading or prefer not to then another method you could use is to delete the file first and then upload it.

To change permissions you can have the script ssh in and run chmod g+w on the file. Or you could set the umask so the default file creation permissions include write permission.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .