Skip to main content

Transferring VM Data to an External Computer via SCP

Secure Copy Protocol (SCP) is a method for securely transferring files between a local host and a remote host or between two remote hosts. This section will guide you on using SCP to transfer data from your GPU VM to an external computer owned by the user.

Prerequisites

  • SSH access to your VM.
  • The external computer must have an SSH server running and accessible.
  • Know the IP address or hostname of the external computer, as well as the username on that system.
  • Ensure the external computer is reachable over the network from the GPU VM.

Step 1: Prepare the External Computer

  1. Ensure SSH Server is Installed and Running:

    • On a Linux or macOS computer, the SSH server is often pre-installed. You can start it with:
      sudo systemctl start ssh
      
    • On Windows, you might need to enable the "OpenSSH Server" feature from the "Apps & features" settings or install it manually.
  2. Check the Firewall:

    • Ensure the firewall on the external computer allows incoming connections on the SSH port (default is 22).

Step 2: Backing Up Your Environment

To back up your Python or Conda environment, create an environment file:

For Conda environments:

conda env export > environment.yml

For Python virtual environments:

pip freeze > requirements.txt

This file should be included with your data backup to recreate your working environment later.

Step 3: Transfer Files Using SCP

  1. Open a Terminal on Your VM.

  2. Execute the SCP Command: To transfer a file or directory from the VM to the external computer, use the following command format:

    scp -r /path/to/local/data username@external-host:/path/to/destination/folder
    
    • Replace /path/to/local/data with the path to the data on your GPU VM you wish to transfer.
    • Replace username with your username on the external computer.
    • Replace external-host with the IP address or hostname of the external computer.
    • Replace /path/to/destination/folder with the path on the external computer where you want to transfer the data.

    Example:

    scp -r /home/ubuntu/myproject username@192.168.1.5:/home/username/data_backup
    

    This command recursively copies the myproject directory from the GPU VM to the data_backup directory on the external computer.

  3. Authentication:

    • Upon executing the command, you may be prompted to enter the password for the username account on the external computer.
    • If you use SSH keys for authentication, ensure the private key is available on your GPU VM, and you may need to specify it using the -i option.
  4. Verify the Transfer:

    • After the transfer completes, log into your external computer and verify that the files or directories have been successfully copied.

Notes

  • The -r option is used to recursively copy entire directories. Omit this option if you're transferring a single file.
  • SCP uses SSH for data transfer, providing a secure channel. Ensure your passwords or private keys are kept secure.
  • If transferring large amounts of data, consider using a wired connection if possible to speed up the transfer.