I can scp to a directory under /home but not under /media. Why?
So for example scp /local/file/path user@192.168.1.xxx /home/more/path
works but scp /local/file/path user@192.168.1.xxx /media/more/path
does not.
You need to have root access to scp
to that directory. So you can try
scp /local/file/path root@192.168.1.xxx /media/more/path
If 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 user@192.168.1.xxx:/home/user/some/path
ssh user@192.168.1.xxx
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
done
I 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
root@192 ...
and enter the password for the remote computer, I get permission denied. I've tried entering the password enough times it's not a typo issue or the like. Any idea? – knl Jun 06 '15 at 04:18