Secure copy protocol facts for kids
Developer(s) | The OpenSSH Project |
---|---|
Written in | C |
Operating system | Cross-platform |
Type | Command, Communication protocol |
The Secure Copy Protocol (SCP) is a way to safely move computer files. It lets you copy files between your computer and another computer far away. You can also copy files between two distant computers. SCP uses a special security system called Secure Shell (SSH).
The people who made OpenSSH said in 2019 that SCP was getting old. They suggested using newer ways to transfer files. These include SFTP and rsync. Because of this, the `scp` program now uses SFTP by default. This makes file transfers even more modern and secure.
Contents
What is Secure Copy Protocol?
The SCP is a network protocol. Think of a protocol as a set of rules for computers to talk to each other. SCP helps computers send files across a network. It uses Secure Shell (SSH) to move data. This means your files are kept safe and private during transfer. SCP makes sure only the right people can see your files.
You can use SCP to send files from your computer to a server. You can also ask a server to send files or folders to your computer. SCP usually works on TCP port 22. This is like a specific door number on a computer.
How SCP Works
When you want to use SCP, your computer connects to the remote computer using SSH. Then, it asks the remote computer to start an SCP process. This process can work in two main ways:
- Source mode: This mode reads files from the remote computer. Then, it sends them back to your computer.
- Sink mode: This mode takes files you send from your computer. It then writes them onto the remote computer.
These modes are like telling the remote computer if it should "send" files or "receive" files.
Copying Between Remote Computers
In the past, copying files directly between two distant computers using SCP was tricky. It sometimes needed special security methods.
Now, SCP can send files between two remote computers by routing them through your computer. This means your computer acts as a middleman. This way, your security details only need to be on your computer. This makes it safer and easier to copy files between two remote places.
The scp Program
The scp program is a tool that uses the SCP rules. It helps you securely copy files. It's a program that does the actual copying.
The most common `scp` program is part of OpenSSH. You can find it on most computers that use SSH. The `scp` program is like a secure version of an older command called `rcp`. The `scp` program also acts as an SCP server. This means it can receive files too. Since 2023, the `scp` program uses the newer SFTP by default. There is a special option, `-O`, if you need to use the older SCP method.
How to Use the scp Program
The `scp` program works a lot like the `cp` (copy) command. Here are some common ways to use it:
Copying a file from your computer to a remote computer: `scp <YourFile> <username>@<remotecomputer>:<folder>/<NewFileName>`
For example, to send a file named report.txt to a server called myserver in the documents folder: `scp report.txt user1@myserver:documents/report.txt`
Copying a file from a remote computer to your computer: `scp <username>@<remotecomputer>:<folder>/<RemoteFile> <YourFolder>/<NewFileName>`
For example, to get a file named notes.txt from myserver to your downloads folder: `scp user1@myserver:notes/notes.txt ~/downloads/notes.txt`
Copying an entire folder from a remote computer (with -r for recursive): `scp -r <username>@<remotecomputer>:<folder>/<RemoteFolder> <YourFolder>/<NewFolder>`
For example, to get a folder named photos from myserver to your pictures folder: `scp -r user1@myserver:data/photos ~/pictures/my_photos`
If the remote computer uses a different port number than 22, you can tell `scp` which one to use. For example, if it uses port 2222: `scp -P 2222 <username>@<remotecomputer>:<folder>/<RemoteFile> <YourFile>`
Other Programs for Secure Copying
SCP is mainly for just transferring files. Because of this, you don't often see graphical programs (GUI) that use only SCP. Programs like WinSCP usually use the SFTP protocol by default. SFTP is more advanced because it can also list files in a folder.
More complete tools for managing files over SSH are called SFTP clients.
Security Concerns
In 2019, a security issue was found with the OpenSSH SCP tool. This issue, known as CVE-2019-6111, could allow someone to accidentally overwrite files in the target folder on the SCP client's computer. This is another reason why using SFTP is now recommended.
See also
In Spanish: Secure Copy para niños
- SSH File Transfer Protocol (SFTP)
- Remote copy (rcp)
- Comparison of file transfer protocols
- Files transferred over shell protocol (FISH)
- FTP over SSH
- FTPS
- rsync
- Secure shell
- WinSCP