I need to automate a file transfer using scp
and I have created a new ssh key and sent the public key to the remote server where I'll be sending files to (@ ~/.ssh).
The problem is that it won't allow me to scp the file anywhere except the home directory. If I transfer it to the home directory, it works fine, but not anywhere else.
Is there something that needs to be done here? Thanks!
If you can scp
the file to your home directory, then your key is working. That is unlikely to be an issue.
The kinds of problems you might have would be:
$ scp test.txt myserver:/root
scp /root/test.txt: Permission denied
In this case you need to get permission to write to the directory, or choose a different destination that you do have access to.
$ scp test.txt myserver:foo/bar/
scp foo/bar: No such file or directory
In this case, check that you're uploading to the correct path.
A destination like myserver:foo/bar/
(note: no /
after the :
) means a relative path to your home directory. So, it might be /home/seumasmac/foo/bar/
in this case.
A destination like myserver:/var/www/
(note: there is a /
after the :
) is an absolute path. It means the directory /var/www/
on the server.
The error that you get when you try to upload should tell you which of the above is the problem in this case.