📜  scp local to ssh aws - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:05:05.809000             🧑  作者: Mango

SCP local to SSH AWS - Shell/Bash

Introduction

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.

Prerequisites

To transfer files between a local machine and an AWS instance using SCP, you must have:

  • A local machine with Shell/Bash installed.
  • An AWS instance running with an accessible IP address.
  • SSH configured and running on the AWS instance.
SCP Syntax

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.
SCP Example

To transfer a file from a local machine to an AWS instance using SCP, follow these steps:

  1. Open a Terminal window (Shell/Bash) and type the following SCP command:
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.
  1. 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.

  2. Enter your password when prompted.

  3. SCP transfers the file from your local machine to the AWS instance.

Conclusion

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.