How To Transfer Files With Secure Copy Protocol

What is SCP Protocol? #

Secure Copy (SCP) is a protocol based on SSH (Secure Shell) that provides secure file transfers between two computers. With SCP, you can quickly transfer files using the command line, which is often faster and easier than using a client with a graphical interface. Additionally, you can use this command-line functionality in your own batch files and scripts to automate file transfers.

 

Using an SCP client #

Follow the appropriate procedure below for your computer’s operating system to use SCP.

 

Windows operating systems #

Microsoft Windows does not include an SCP client, so you must download one first. Heaven Hoster recommends PSCP, a free program that you can download here.

After you have downloaded the PSCP executable to your local computer, you should add the directory where pscp.exe is located to your path so you can run it from any directory. After you do this, you are ready to transfer files to and from your Heaven Hoster. To do this, follow these steps:

 

  1. Open a DOS command window. To do this, click Start, click Run, type cmd, and then press Enter.
  2. To upload a file to your Heaven Hoster account, type the following command. Replace both occurrences of username with your Heaven Hoster username, and example.com with your site’s domain name. Additionally, replace file with the name of the file on your local computer that you want to upload, and replace destination with the destination directory on your Heaven Hoster account:
    pscp -P 7822 file username@example.com:/home/username/destination
    • Make sure you use an uppercase P to specify the SCP port number.
    • The default SCP port number for SSH is 22.
  3. Type your password when you are prompted to do so. PSCP uploads the file to the destination directory that you specified.
  4. To download a file from your Heaven Hoster account, type the following command. Replace both occurrences of username with your Heaven Hoster username, and example.com with your site’s domain name. Additionally, replace file with the name of the file on your Heaven Hoster account that you want to download, and replace destination with the destination directory on your local computer:
    pscp -P 7822 username@example.com:/home/username/file destination
    To download the file to the current directory, type a period (.) for the destination.
  5. Type your password when you are prompted to do so. PSCP downloads the file to the destination directory that you specified.

    There are a few additional options that you may find useful when working with PSCP:

    • The -p option preserves the original file’s attributes, such as modification and access times.
    • The -r option enables you to recursively copy entire directories. For example, if you want to download the entire public_html directory to the current directory on your local computer, type the following command:
      pscp -r -P 7822 username@example.com:/home/username/public_html .
    • To view a list of all PSCP options, type pscp at the command line.
Mac OS X and Linux operating systems #

Both Mac OS X and Linux include the scp client program, so you do not have to download a special client. To use the scp program, follow these steps:

  1. Open a terminal window. The procedure to do this depends on your operating system and desktop environment.
    • On Mac OS X, click Applications, click Utilities, and then click Terminal.
  2. To upload a file to your Heaven Hoster, type the following command. Replace username with your Heaven Hoster username, and example.com with your site’s domain name. Additionally, replace file with the name of the file on your local computer that you want to upload, and replace destination with the destination directory on your Heaven Hoster account:
    scp -P 7822 file username@example.com:~/destination
    • Make sure you use an uppercase P to specify the SCP port number. Note that this is the opposite of the ssh client program, which uses a lowercase p to specify the SCP port number.
    • The default SCP port for SSH is 22. However, Heaven Hoster uses a different port for security reasons.
  3. Type your password when you are prompted to do so. Scp uploads the file to the destination directory that you specified.
  4. To download a file from your Heaven Hoster account, type the following command. Replace username with your Heaven Hoster username, and example.com with your site’s domain name. Additionally, replace file with the name of the file on your Heaven Hoster account that you want to download, and replace destination with the destination directory on your local computer:
    scp -P 7822 username@example.com:~/file destination
    To download the file to the current directory, type a period (.) for the destination.
  5. Type your password when you are prompted to do so. Scp downloads the file to the destination directory that you specified.

    There are a few additional options that you may find useful when working with scp:

    • The -p option preserves the original file’s attributes, such as modification and access times.
    • The -r option enables you to recursively copy entire directories. For example, if you want to download the entire public_html directory to the current directory on your local computer, type the following command:
      scp -rP 7822 username@example.com:~/public_html .
    • To view the complete scp documentation, type man scp at the command line.
error: