Web Hosting - Copy files using SCP command
Objective
With the Secure Copy Protocol (SCP), you can securely copy data between two devices (using SSH protocol). You can copy content:
- Present locally from your computer to a remote device.
- From a remote device to your computer.
- From one server to another (unavailable between two OVHcloud web hosting plans).
It allows you to copy a file or folder containing one or more files from a terminal using a Linux command.
OVHcloud provides services for which you are responsible with regard to their configuration and management. It is therefore your responsibility to ensure that they function correctly.
This guide is designed to help you with common tasks. Nevertheless, we recommend contacting a specialist service provider if you encounter any difficulties. We will not be able to assist you. You can find more information in the Go further section of this guide.
This guide explains how to use the Secure Copy Protocol (SCP) command in SSH to copy files to and from your Web Hosting plan.
Requirements
- A terminal compatible with Linux and SSH commands (for example, the terminal of MacOS or the Ubuntu emulator on Windows)
- Familiarity with Linux and SSH commands
- A web hosting plan with SSH access
- Access to your OVHcloud Control Panel
Instructions
This guide will provide a non-exhaustive list of the features available with the scp command. Please feel free to chat with our community of users if you would like to learn more.
Step 1 - Retrieve SSH access from your web hosting plan
To find the SSH access for your web hosting plan, please read our guide on Using SSH access for your web hosting plan.
Step 2 - Retrieve the full path to your web hosting plan’s FTP storage space
Open your terminal and connect to your web hosting plan via SSH.
Once you have logged in to your web hosting plan via SSH, enter the following command:
Confirm the command using the Enter(↲) key on your keyboard, then enter the following command:
Confirm this second command using the Enter key (↲) on your keyboard.
In your terminal, a result similar to our example below will appear:
In our example:
FTP-login: The name of one of the FTP users (primary or non-primary) of your web hosting plan./homez.XXX: filer on which your web hosting plan is located.FTP-main-login: Directory path of your web hosting plan’s FTP storage space. This directory is usually named the same as your web hosting plan’s main FTP login.
In our example, the full path to the FTP storage space to access the web hosting plan’s FTP root is: /homez.XXX/FTP-main-login.
Only from a directory equivalent to the directory FTP-main-login of our example will you be authorised to use the scp command.
When you log in to a web hosting plan’s FTP space in the usual way, you can log in directly from the folder equivalent to the FTP-main-login folder in our example.
This is where your web hosting plan’s www folder and .ovhconfig file are located by default.
Step 3 - Use the "scp" command with your web hosting plan
All of the commands below are carried out from your device's terminal locally. You do not need to first establish an SSH connnection to your web hosting plan.
The file path used with the scp command is relative to the current local directory. To transfer data to your web hosting or from the web hosting to your local device, be sure to execute your commands from the local parent directory, as shown in the examples below.
Remember to replace all of the following general settings with your own:
FTP-login: FTP login for your web hosting plan.ssh.cluster0XX.hosting.ovh.net: ReplaceXXwith the cluster number where your web hosting plan is located. If you need any further information, please refer to our guide on Using SSH access on your web hosting plan./homez.XXX/FTP-main-login/: ReplaceXXXwith the number of the filer and theFTP-main-loginby the parameters retrieved in step 2 of this guide.source_folder: The name of the source folder to be copied or in which the file to be copied is located. If the file path contains nested folders, specify all the folder names separated by a/.target_folder: The name of the target folder that will receive the local folder or file to copy. If the file path contains nested folders, specify all the folder names separated by a/.file: The name of the file to be copied using thescpcommand. Please also remember to specify the extension of this file (examples: .html, .css, .php, .txt, etc.).
Copy content from your local device to your web hosting plan
To copy a single local file to your web hosting plan, use the following command:
To copy a local folder and all of its contents to your web hosting plan, use the following command:
Copy content from your web hosting plan to your local device
To copy a single file from your web hosting plan to your local device, use the following command:
To copy a folder on your web hosting plan and all of its files to your local device, use the following command:
Copying content from your OVHcloud web hosting plan to another OVHcloud web hosting plan
For security reasons, the scp command is refused by the OVHcloud web hosting infrastructure when trying to move data from one hosting to another.
Step 4 - Make sure the content has been copied
To check that content on your computer has been copied to your web hosting plan, you can log in to your web hosting plan’s FTP storage space, then go to the target directory where the content is supposed to be.
To check that content on your web hosting plan has been copied locally on your computer, go to the target directory on your device/computer, then check that the content that is supposed to be copied is there.
Go further
Accessing a web hosting plan via SSH
Logging in to your web hosting plan’s FTP storage space
For specialised services (SEO, development, etc.), contact OVHcloud partners.
Join our community of users.