Transferring files using SCP (Secure Copy)

Secure Copy (SCP) is a quick and secure way to transfer files to and from your hosting.com account by using the command line. Learn how to use SCP here.

This article describes how to use SCP (Secure Copy Protocol) to transfer files quickly and securely from the command line.

What is SCP?

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.

📘

Note

For information about how to securely transfer files using a client with a graphical interface, please see this article.

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. hosting.com recommends PSCP, a free program that you can download here.

📘

Note

PSCP is part of the PuTTY tool suite for Windows. For information about how to access your account using SSH and PuTTY, please see this article.

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 hosting.com account. 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 hosting.com account, type the following command. Replace both occurrences of username with your hosting.com 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 hosting.com account:

    pscp -P 7822 file [email protected]:/home/username/destination
    

    📘

    Note

    • Make sure you use an uppercase P to specify the SCP port number.

    • The default SCP port number for SSH is 22. However, hosting.com uses a different SCP port for security reasons.

  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 hosting.com account, type the following command. Replace both occurrences ofusername with your hosting.com username, and example.com with your site's domain name. Additionally, replace file with the name of the file on your hosting.com account that you want to download, and replace destination with the destination directory on your local computer:

    pscp -P 7822 [email protected]:/home/username/file destination
    

    👍

    Tip

    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.

    👍

    Tip

    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 [email protected]:/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 hosting.com account, type the following command. Replace username with your hosting.com 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 hosting.com account:

    scp -P 7822 file [email protected]:~/destination
    

    📘

    Note

    • 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, hosting.com 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 hosting.com account, type the following command. Replace username with your hosting.com username, and example.com with your site's domain name. Additionally, replace file with the name of the file on your hosting.com account that you want to download, and replace destination with the destination directory on your local computer:

    scp -P 7822 [email protected]:~/file destination
    

    👍

    Tip

    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.

    👍

    Tip

    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 [email protected]:~/public_html.
    
    • To view the complete scp documentation, type man scp at the command line.

More Information

For more information about SCP, please visit http://en.wikipedia.org/wiki/Secure_copy.

Related Articles