Skip to content

Instantly share code, notes, and snippets.

@SofijaErkin
Last active June 26, 2022 01:22
Show Gist options
  • Save SofijaErkin/bb59afe064fcc397f5f687efb9fa534c to your computer and use it in GitHub Desktop.
Save SofijaErkin/bb59afe064fcc397f5f687efb9fa534c to your computer and use it in GitHub Desktop.
using scp command between two machine.

SCP Command Combat Style

1.Summary

SCP: Copy a File Between Two Systems

2.Usage

scp [OPTION] [user@]SRC_HOST:]file1 [user@]DEST_HOST:]file2

Notice:

In SCP command,

-P - Specifies the remote host ssh port.

-p - Preserves files modification and access times.

In SSH command,

-p - Specifies the remote host ssh port.

3.Combat case

You know there are less than one more program running in remote cloud/VM. E.g:

there is a program b.py, that is dependent on another program a.py, if

this case occurs, we should push that two program into remote cloud/VM to run.

Now, that's time to use scp(secure copy). package them and copy, copy that

into my VM's folder macos_share via:(From Host to Guest VM)

scp -P target_port ~/{a,b}.py [email protected]:~/macos_share

and if into my remote Cloud's folder macos_share_cloud, then via:

(From remote cloud or other host to guest VM)

scp -P target_port ~/{a,b}.py [email protected]:~/macos_share_cloud

then run that transmitted copied file, that means product a instruct to active

a.py via ssh command with " and "(From Host to Guest VM):

ssh -p target_port [email protected] "python3 ~/macos_share/a.py"

and if run in remote cloud, then via(From remote cloud/other host to guest VM):

ssh -p target_port [email protected] "python3 ~/macos_share/a.py" 

Finally, if want to copy the result to the local machine, then use scp, again:

(From Host yo Guest VM)

scp -P target_port [email protected]:~/macos_share/a.py ~/Desktop/ 

and if from cloud to local, then(From cloud or other host to guest VM):

scp -P target_port [email protected]:~/macos_share_cloud/a.py ~/Desktop/ 

4.Refer

1.Remote Copying With the scp Command.

2.MacOS access VM Ubuntu using SSH and the operation of Cloud(Chinese Blog).

3.How to Use SCP Command to Securely Transfer Files.

4.SSH Command.

5.SCP Command(Chinese Blog).

6.Target Port to transmit files via SCP(Chinese Blog).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment