Image

Knowledge base → Transfer files over SSH using SCP

[Virtual servers]
Date of publication: 06.03.2024

To transfer files from one server to another via SSH, we often use the SCP utility and in this guide we will provide examples of its use.

1. Transfer a file from a local server to a remote one

scp /path/to/local/file user@serverip:/path/to/remote/file

1.1 Transfer indicating the port number on which SSH is running

scp -P 2221 /path/to/local/file user@serverip:/path/to/remote

1.2 Transferring the entire folder specifying the SSH port number

scp -P 2221 -r /path/to/local/ user@serverip:/path/to/remote

2. Transfer a file from a remote server to the current one

scp user@serverip:/path/to/remote/file /path/to/local/file

2.1 Transferring a file from a remote server to the current one specifying the SSH port

scp -P 2221 user@serverip:/path/to/remote/file /path/to/local/

When executing commands, a message will be displayed asking you to accept an SSH signature, after which you will be asked for a password from the user being used.

This method is convenient and is an alternative solution to WinCSP, XShell and the like, since the task is to show the method of transferring files in the console.





No Comments Yet