$ scp localfile.txt user@server:/target/dir
Scp send & receive files on unix
Upasana | July 13, 2020 | 1 min read | 40 views
Scp is widely used unix utility to send and receive files from remote server in a secure fashion. It supports password based authentication as well as password less RSA based authentication mechanism. We can either send/receive a single file or the entire directory using single command.
To send a file from local machine to remote server using scp
Login to your local machine from where you want to send file from. Then, run the below commands.
To send a single file to remote server (using password)
Send a single file to server using Public Key Auth (pem file)
$ scp -i mykey.pem localfile.txt user@server:/target/dir
To send directory to remote server (using password)
$ scp -r /copy/from/dir/ user@server:/copy/to/dir
To receive a file from remote server using scp
To receive a file or directory from remote server, arguments to scp command are reversed. You need to login into local machine where you want to download the files and run the below command:
Receive a single file using password
$ scp username@remote:/copy/from/file /copy/to/dir
Receive a single file using public key authentication (pem file)
$ scp -i ~/mykey.pem user@server:/copy/from/file /copy/to/file
Receive entire directory using SCP
$ scp -r username@remote:/copy/from/dir /copy/to/dir
Top articles in this category:
- Basic Unix commands for every programmer
- DevOps interview questions - Basic Concepts, Microservices, Databases, AWS
- Upgrade Jenkins on Ubuntu 18.04 LTS
- Install RabbitMQ and Erlang 23 on Ubuntu 20
- Install & configure Redis on Ubuntu
- Install OpenJDK 11 on Ubuntu 18.04 LTS
- MySql 8 installation on Ubuntu 20
Recommended books for interview preparation:
Book you may be interested in..
Book you may be interested in..