I can scp to a directory under /home but not under /media. Why?
So for example scp /local/file/path /home/more/path works but scp /local/file/path /media/more/path does not.
1 Answer
You need to have root access to scp to that directory. So you can try
scp /local/file/path /media/more/pathIf that does not work you would have to scp to somewhere in the home directory and then move it to the /media directory. You could also do this through ssh if you know the root password.
scp /local/file/path :/home/user/some/path
ssh
sudo mv /some/path/file /media/You can also use a script to move the file to /media directory when you scp a file to the remote machine. You can use the following script.
#!/bin/bash
while true
do sleep 10 contents=$(ls -A /home/user/directory) if [ $contents ] then sudo mv /home/user/directory/* /media/ fi
doneI would recommend you to have an empty directory into which you can copy the files to. The script will move the contents of the directory to /media/ every 10 seconds. You can use different numbers after sleep depending on the frequency you want the script to run. You will still have to enter the password to move the files however, If you do not want to enter the password, see this answer.
Note: If the number is too small, It may affect your computers performance depending on the hardware
11