Code:
scp filename1 name@website:filename2
filename2 means that filename1 will be loaded onto the server and renamed as filename2 at the same time. Basically the syntax of a scp command is similar to that of cp. You have just to take in mind that to specify a remote path the syntax is
Code:
user@host:/path/to/remote/file
where the hostname (or IP address) and the colon are mandatory. If you omit the username, scp will try to connect using the same username as in your local machine. From what stated above, you can copy to a spcecific loaction on the remote server, by typing the path immediately after the colon:
Code:
scp filename1 user@host:/home/user/my_files/
this will copy your local file to the directory /home/user/my_files/ on the remote host. You can also use relative path, taking in mind they refer to your home directory on the remote server. If your home was /home/user in the example above, you could also do simply:
Code:
scp filename1 user@host:my_files/
Some useful options of scp are -p to preserve the timestamp of the original file and -r to recursively copy a directory or an entire directory tree. For example:
Code:
scp -pr /path/to/your/local/dir user@host:
Since I did not specify any path on the remote server (but not the mandatory ":" at the end) this will copy the local directory to your home dir on the remote host.
Finally, you may have some problem to specify file names on the remote server if they contain blank spaces. The correct way to do that is to double escape them so that a single escape character is passed intact to the remote server:
Code:
scp -pr user@host:"/path/to/dir\\ with\\ spaces/" .
moreover, this show you how to retrieve a directory (or a file) in the opposite way: FROM the remote server to the LOCAL machine (in this specific example to the current directory "."). Hope this helps.