Using the Secure Copy command (scp) from the command prompt
There are occasions when you may want to push or pull a file from
one machine to another from the command line. For example, recently
I needed to restore a configuration file from a backup machine to
a production machine after a disk failure and subsequent software
reinstallation.
In the following scenarios, replace the
machine1 and machine2 listings with the IP addresses
or domain names of your machines.
Scenario 1:
The file was located on machine1 and needed to be moved (pushed)
to machine2. The command below identifies the file on machine1
and securely copies it to machine2:
[root@machine1 /root]# scp /etc/aspseek/sites.conf machine2:
You will be prompted for the root password. When successfully
authenticated, the file will be scp'ed into the /root directory of
machine2, from which it was easily moved to the proper directory.
Scenario 2:
The file "removecore.sh" was located on machine2 and needed
to be moved (pulled)onto machine1:
[root@machine1 /root]# scp machine2:/root/removecore.sh /root
Once again, you will be asked to authenticate with the root password.
If successful, the removecore.sh script will be scp'ed to the /root
directory of machine1.
Of course, you can skip all the command line stuff if you simply open
up two sessions of WinSCP (one for machine1 and one for machine2), and
then just drag-and-drop the files back and forth between the two. ;-)