Score:0

ssh can't create file in network folder and write to it in the same operation

bz flag

Let me preface my question by saying that I don't need to use cp I was just trying cp to diagnose a deeper issue related to file creation during another process.

So when I ssh from Windows to a Linux server and try cp from the command line the first attempt fails with the error "cannot create regular file ... : Operation not permitted". The result of this is that it creates the file I am copying but leaves it empty. When I run the command again, leaving the existing empty file from the first attempt, I don't get an error and it copies the contents of the file to the existing file. I get the same result if I create the empty file in Windows and then use cp in ssh. This is writing a file to a shared network folder formatted with NTFS.

So my problem is that it doesn't seem to be able to create the file and write to it in the same operation, but if it creates the file first or it already exists it is then able to overwrite it.

The process I am trying to debug creates temp files with random names so I can't anticipate the file names and create empty ones ahead of the process. The result is a failed process with empty temp files. Any thoughts on where to look for the problem behind this issue?

Edit: When I cp the same file to a local temp directory it succeeds in creating and writing the file into the temp directory. The resulting file seems to have the same file permissions as the network version that fails.

Edit: In reply to user68186

Q Which version Ubuntu are you using? Looks like it's not Ubuntu so I guess I'm in the wrong place. It's Oracle Linux Server v8.4.

Q Do you ssh as a normal user, an admin user, or root? I believe it is as a normal user.

Q What is the ownership and permissions for the folder where you are trying to copy the file? drwxrwxr-x. 2 1073 1140 3 Jul 2 08:21

ar flag
Which version Ubuntu are you using? When you `ssh` into the "Linux server" do you ssh as a normal user, an admin user, or root? What is the ownership and permissions for the folder where you are trying to copy the file? Please [edit your question](https://askubuntu.com/posts/1349453/edit) and put all the new information there.
ar flag
Use the following command in the ssh terminal `ls -dl /path/to/the/folder/` and copy and paste the output in your question. This will tell us who owns the folder and what read-write permissions others have.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.