SCP: Copy a File Between Two Systems
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.
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/
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.