- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud
- Security

Transfer Files Securely Over the Network
Among a system administrator's duties is having to transfer files between systems. But sending files across a network can be a security problem, so we need to encrypt things using the tools available with SSH in order to keep our data safe while it's in transit. This activity will get us familiar with secure file transfers using SSH-based tools, like `scp` and `rsync`. Once this activity is complete, we'll know when to copy files or to synchronize them, and understand the difference between "pushing" and "pulling" file transfers over the network securely.

Lab Info
Table of Contents
-
Challenge
Recursively List the opt Directory on server1 and server2
Once we're logged in, let's take a look at the directories we've got to work with:
Use
ls -lR /opt/
locally onserver1
, and then execute it remotely onserver2
withssh
:ls -lR /opt ssh server2 ls -lR /opt
-
Challenge
Securely Copy the /opt/myapp Directory from server1 to the /opt Directory on server2
Now let's use
scp
to recursively copy/opt/myapp
onserver1
into/opt
onserver2
. The-r
option makes it recursive, and-p
makes it preserve time stamps and permissions. Since we should be logged intoserver1
, we can omit the host portion of the source directory:scp -rp /opt/myapp server2:/opt
-
Challenge
Synchronize the /opt/myapi Directory from server2 with server1
We can use the
rsync
command to pull the/opt/myapi
directory onserver2
into/opt
onserver1
:rsync -aP server2:/opt/myapi /opt
-
Challenge
Verify That the /opt/myapp and /opt/myapi Directories Are the Same on server1 and server2
To make sure everything is in sync, we can run
ls -lR /opt/
locally onserver1
and execute it remotely onserver2
with anssh
command. Then we can use thersync
command to verify that the content, time stamps, and permissions are the same:ls -lR /opt ssh server2 ls -lR /opt rsync -naP /opt/ server2:/opt
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.