📅  最后修改于: 2023-12-03 15:05:05.809000             🧑  作者: Mango
SCP (secure copy) is a command-line tool used to transfer files securely between a local host and a remote host over an SSH protocol. In this tutorial, we will learn how to transfer files from a local machine to an AWS instance using SCP in the Shell/Bash environment.
To transfer files between a local machine and an AWS instance using SCP, you must have:
The syntax of SCP command is as follows:
scp [options] [source] [destination]
Where,
[options]
- SCP command options, such as -r
to copy directories recursively.[source]
- The path and file name of the file or directory you want to transfer.[destination]
- The destination path and name of the file or directory on the remote host.To transfer a file from a local machine to an AWS instance using SCP, follow these steps:
scp /path/to/local/file.txt username@aws-instance:/path/to/remote/directory
Where,
/path/to/local/file.txt
- The path and name of the file you want to copy from your local machine to the AWS instance.username
- The username you use to log in to the AWS instance.aws-instance
- The IP address or DNS name of the AWS instance you want to transfer the file to./path/to/remote/directory
- The path and name of the directory on the AWS instance where you want to store the file.If this is the first time you connect to the AWS instance, SSH prompts you to add the host key to your known_hosts file. Type "yes" and press enter.
Enter your password when prompted.
SCP transfers the file from your local machine to the AWS instance.
In this tutorial, we learned how to use SCP to transfer files from a local machine to an AWS instance using Shell/Bash. SCP is a powerful and secure tool that allows you to transfer files between machines over an SSH protocol.