How to Transfer Files over the Private Network

Directing commands like ping or rsync at a public IP address will automatically route the traffic over the public network. However, when using an IP address on the private network, the traffic stays on the private network.

If you have two Droplets in the same datacenter with private networking enabled, you can transfer files between them over the private network. We recommend doing so with SSH keys because they’re more secure, but you can also skip the SSH key setup and transfer files using password authentication.

Set Up SSH Keys

If you added SSH keys to your Droplets when you created them, your Droplets will have password authentication disabled. This protects the servers against password vulnerabilities but also means that to connect directly from one server to the other, you need to create and authorize SSH keys.

To transfer files from Droplet-01 to Droplet-02, SSH into Droplet-01 and create a new RSA key.

ssh-keygen

Next, print the public key in ~/.ssh/id_rsa.pub to your terminal, then copy it your clipboard.

cat ~/.ssh/id_rsa.pub
ssh-rsa EXAMPLEzaC1yc2EAAAADAQABAAABAQD7lpFBPqtQqCWFjDKCNhPLcfAi3musaXFgkzdHJ   3uO+9I/RZT662oSvyGp/yW2aOzduWYiv9ILgHH7vb/m5Y/iRvkBXr382x8ea4TCc3eD1fZ6DFF2  6ybsTTftK4zIaWfCeb8+K4CHCFngBpbSm/YWTTicff3PIli3gr6ZrYu13Csao/Y3KfHiUPjHXif+5wd  VYTD9j+WBpmYSX3mh7DS2KLdvMA+cTrQz7tpe06DwPDD5h1FDgtmHJGlsh07ohpUE1eYja  WxPYzGCtaDFJkP7DemR6UL/v5MP2yiFXV22ab/q5ud+7wnjnpxO+tE0Vk45MqJg/7KBVErBczd  lAwPT root@Droplet-01

Then, SSH into Droplet-02 and paste the public key into its authorized key file.

echo "EXAMPLEzaC1yc2E...lAwPT root@Droplet-01" >> ~/.ssh/authorized_keys

Transfer Files

From here, you can transfer files from Droplet-01 to Droplet-02 over the private networking using Droplet-02’s private IP address. For example, using rsync:

rsync --verbose /path/to/file  198.51.100.0:/path/to/target/location

If you added a passphrase to Droplet-01’s SSH key pair, you’ll be prompted to enter it. If you’re using password authentication on your Droplets, you’ll be prompted to enter your password for Droplet-02.

You can verify that the transfer was successful by SSHing into Droplet-02 and looking for the file in the target location.