1.4 KiB
1.4 KiB
RHCSA 4.7: Secure file transfer
Copying files to and from another machine with scp, rsync and sftp, keeping permissions and times.
Before you start
The peer, at 10.99.0.2 (name peer), stands in for the other VM. It
runs its own sshd, and shares this VM's files and users, so your account
there needs to be a different user to keep the copies apart: you are
alice here, and bob on the peer.
The lab creates users alice and bob (password Lab-Pass-1). alice
has an SSH key that logs in as bob@peer, a directory ~/proj with a
few files (one of them mode 640, all dated January 2026), and a file
~/report.txt. Do the tasks as alice: sudo su - alice.
Tasks
- Copy the directory
~/projto bob's home directory on the peer (bob@peer:), keeping permissions and modification times. - Fetch
/etc/os-releasefrom the peer into a local directory~/got. - Copy
~/proj/tobackup/in bob's home on the peer with rsync, change one file in~/proj, and copy again. The second run lists only the changed file. - Use sftp to upload
~/report.txtto/tmpon the peer, and download it again as~/report-back.txt.
Hints
scp -rp proj bob@peer:;ssh bob@peer ls -l proj.scp bob@peer:/etc/os-release ~/got/; the directory must exist.rsync -av proj/ bob@peer:backup/; the trailing slash copies the contents.sftp bob@peer, thenput,get REMOTE LOCAL,bye.