## How to Securely copy a file from a local machine to a remote machine in Linux:
**Syntax:**
```shell
scp [file_name] remoteuser@remotehost:/remote/directory
```
What's happening here:
- file_name = The name of the file that needs to be copied.
- remoteuser =The username of the remote host.
- remotehost = The IP address or hostname of the remote host.
- /remote/directory = The directory where the file should be copied on the remote machine.
**For example:** If we want to copy a file name `test.txt` from local system to a remote system
```shell
scp test.txt
[email protected]:/home/jayesh
```
- “remoteuser” = “Jayesh”
- “remotehost” = “10.143.90.2”
- “/remote/directory” = “/home/jayesh”
## How to Securely copy a file from remote machine to our local machine:
**Syntax:**
```shell
scp user@remotehost:/home/user/file_name
```
What's happening here:
- “user” = username of remote system.
- “remotehost” = IP address (or hostname) of remote system.
- “/home/user/file_name” = path of file that has to be copied.
- “.” = this means that we are copying that file in current location in local system.
**Syntax:**
```shell
scp
[email protected]:/home/jayesh/test1.txt
```
- “user” = jayesh
- “remotehost” = 10.143.90.2
- “home/user/file_name” = home/jayesh/test1.txt
### Using non-standard ports:
It is used to Securely Copy File to a Remote Machine on a Non-Standard SSH Port and specify the port to connect on the remote host. It is useful when our [SSH](https://www.geeksforgeeks.org/introduction-to-sshsecure-shell-keys/) server is listening on a non-standard port.
**Syntax:**
```shell
scp -P port source_file user@hostname:destination_file
```