How do I copy files from one domain name to another using the shell?

This page is showing a generic answer.
To see a more detailed answer customized for you, type your domain name here:

If you have multiple domain names hosted with us, we assign each domain name a different Unix user ID to prevent cross-site contamination.

However, occasionally customers who use the command-line shell need to copy files between those domain names. You can do that using rsync or other SSH tools. For example, if you run this command from the shell when logged in as example.com, it will copy the directory “mydirectory” and all its contents from the other domain name “example.net” to “example.com”:

Note that the final “trailing slash” symbol at the end of mydirectory/ below is necessary in both cases to make sure you’re copying the directory to the right location.
rsync -av example.net@example.net:~/html/mydirectory/ ~/html/mydirectory/

And this command will copy the single file “myfile”:

scp example.net@example.net:~/html/myfile ~/html/

By the way, the first time you run them, the commands above will tell you “The authenticity of host 'example.net' can't be established ... Are you sure you want to continue connecting (yes/no)?”. This is normal, and you should choose “yes”.

How do I do this without a password?

If you try the commands above, you’ll see that they ask you for the password of the other site (perhaps a couple of times). That’s fine, but if you need to automate this, technically advanced users can use SSH keys to avoid requiring a password.

To do this, create a key on the “source” domain name you’ll be connecting from by typing ssh-keygen -t rsa and saving it without a password, like this:

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ex/example.com/.ssh/id_rsa):
Created directory '/home/ex/example.com/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ex/example.com/.ssh/id_rsa.
Your public key has been saved in /home/ex/example.com/.ssh/id_rsa.pub.

Then copy the contents of the new “id_rsa.pub” key to the “destination” server (example.net in this example). An easy and safe method is to use the “ssh-copy-id” command:

ssh-copy-id example.net@example.net

After doing this, you should be able to copy files from the other domain name to the source domain name using rsync or scp without a password.