- Lab
- A Cloud Guru
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.
Path 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
What's a lab?
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.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.