How to Copy a File from/to a Remote Server (2024)

scp command is being used to copy files from a remote server to a local machine and vice versa. It uses ssh to do secure file transfer.

1. Copy a file from a remote server to a local machine

It will ask the password for remote user

* symbol can be used to copy multiple files by pattern like w3docs* which will copy w3docs.sql, w3docs1.pdf and etc.

2. Copy a directory from a remote server to a local machine

-r should be used for directories

3. Copy a file from a local machine to a remote server

scp /local/file/path username@example:/remote/path

4. Copy a directory from a local machine to a remote server

-r should be used for directories

scp -r /local/directory/path username@example:/remote/directory/path

5. Copy files by using RSA keys

If there is an identity key (RSA) instead of password than -i should be added

scp -i /path/to/key [emailprotected]:/remote/path/to/file /local/path
How to Copy a File from/to a Remote Server (2024)
Top Articles
Latest Posts
Article information

Author: Nathanael Baumbach

Last Updated:

Views: 6418

Rating: 4.4 / 5 (55 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Nathanael Baumbach

Birthday: 1998-12-02

Address: Apt. 829 751 Glover View, West Orlando, IN 22436

Phone: +901025288581

Job: Internal IT Coordinator

Hobby: Gunsmithing, Motor sports, Flying, Skiing, Hooping, Lego building, Ice skating

Introduction: My name is Nathanael Baumbach, I am a fantastic, nice, victorious, brave, healthy, cute, glorious person who loves writing and wants to share my knowledge and understanding with you.