Lab 3b Chapter 4: Archive and Transfer Files
/25
Submit your screenshots/commands in this file
1. Manage Compressed tar Archives On your Linux VM on ACE (7 points)
Take screenshot after each step
Set user as root in the terminal.
-
Using the du -sh command, What’s the size of your /etc directory? 31M
-
Use the following command to create a tar archive of /etc: cf etc.tar /etc
What’s the size of this archive? Is compression used? 29M, No Compression
-
gzip compression is the earlier, fastest method, and is widely available across platforms. Use the
following command to create a tar with gzip compression: tar czf etc.tar.gz /etc
What’s the size of this archive? 6.9M
-
bzip2 compression creates smaller archives but is less widely available than gzip. Use the
following command to create a tar with bzip2 compression: tar cfj etc.tar.bz2 /etc
What’s the size of this archive? 5.9M
-
xz compression is newer, and offers the best compression ratio of the available methods. Use the
following command to create a tar with xz compression: tar cfJ etc.tar.xz /etc
What’s the size of this archive? 4.8M
-
Create a directory etc_data, then extract the etc.tar (The first one you created) to this location
with tar xf etc.tar -C etc_data. Show the content of etc_data/etc
-
You can also view both compressed and uncompressed size of an archive. Use the gzip -l
etc.tar.gz and xz -l etc.tar.xz commands to see the sizes it would take as if they would be
uncompressed.
2. Working with SSH On your Linux VM on ACE (8 points)
Verify that the ssh daemon is started on your system.
What command did you execute to verify this? systemctl status sshd
SSH Known Hosts
Use the ssh command from the terminal to connect to the server with the IP 10.157.128.196 and the
username linux2
Since you've never connected to this server before, you are prompted as to whether you want to trust the
server.
Type the word yes and press Enter.
The 10.157.128.196 server's public key is then written into the ~/.ssh/known_hosts file, and any
subsequent connections to this IP by the logged on user would only be trusted if the same public key is
presented.
Continue to logon normally using the password Pa$$w0rd
Disconnect from the SSH connection.
Connect again to the 10.157.128.196 server using SSH with the username linux2 and the password
Pa$$w0rd.
Notice that because you said yes previously, you are not prompted about whether to save the server's
public key again.
Close the SSH connection.
Take a screenshot showing the contents of the ~/.ssh/known_hosts file, be sure the filename and path
are visible.
Using SFTP to transfer files
Create a /home/<username>/backup directory
sftp is the Secure File Transfer Protocol, which is a replacement for the older clear-text FTP. SFTP is part
of the Open SSH suite, and uses SSH to encrypt file transfers between remote systems. SFTP allows you to
connect to a remote system and browse their file system before downloading a file, or to specify a file
without browsing that you want to copy to a local system.
Use the command sftp to connect to the 10.157.128.196 SSH server using the SFTP protocol. Logon
using Pa$$w0rd as the password.
Take a screenshot showing the sftp session
Type ls -l to browse the student user's home directory on the remote system.
Because the sftp program doesn't transmit the ls colour code, using ls -l helps you distinguish between
files and directories.
Type the command pwd to view the current directory on the remote system.
Type the command lpwd to view the current directory on the local system.
It is important to know which directory is current on the local system, because SFTP will treat your
current local directory as the source and destination on the local system when you execute SFTP
commands.
Change the local current directory to the newly created /home/<username>/backup directory.
sftp> lcd /home/<username>/backup
sftp> lpwd
Take a screenshot from your work
The command put would be used to upload a file from the local system to the remote system. The
command get would be used to download a file from the remote system to the local system.
Recursively copy the file under Desktop/filetocopy.txt from the remote system to the
/home/student/serverbackup directory on your VM.
sftp> get Desktop/filetocopy.txt
Exit from the sftp session. Verify that the file from the remote system is copied to the
/home/<username>/backup directory on the your VM.
Take a screenshot from your work
3. Section 4.6: Guided Exercise: Synchronize Files Between Systems Securely (4 points)
Take screenshots from
- Step 5 showing the output of the rsync command highlighting the one file that has been
sync'd.
-
Step 6 the command's output and highlight the Log file synchronized line that logger
created.
4. Lab Section 4.7: Archive and Transfer Files (6 points)
Q1: What command did you use to synchronize the /etc directory tree from servera to the
/configsync directory on server? (/1) rsync -av root@servera:/etc /configsync/
Q2: What command did you use to create a configfile-backup-servera.tar.gz archive with the
/configsync directory contents? (/1) tar -czf configfile-backup-servera.tar.gz /configsync
Q3: Take a screenshot(s) that shows you are logged in using sftp on workstation and
uploaded the configfile-backup-servera.tar.gz file (/2)
Q4: What command did you use to extract the configfile-backup-servera.tar.gz archive? (/1)
tar -xzf ~/configfile-backup-servera.tar.gz
Insert a screenshot from the lab grade archive-review script at the end (/1)
Make sure to open a CMD window, place it over your finished grading script and type in the following
two commands date /t followed by hostname. Take a screenshot using Windows Key+Shift+S or use the
snipping tool. This is required to validate that the screenshot is truly your screenshot.
Paste your screenshot Here
Don’t forget to shut down your lab environment so you don’t run out of lab hours, you can increase
the Auto-destroy time and add more time to the Auto-stop than the default of 1 hour using the buttons
listed with the red arrow.