1.7 KiB
1.7 KiB
Linux+ 1.6.2: Copies, syncs and disk images
Mirroring a directory with rsync, pulling files from another machine over SSH, and imaging a disk with dd.
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 its /etc is this
VM's /etc. The lab creates user alex (password Lab-Pass-1) and adds a
small 64 MiB spare disk, /dev/loop40 (the chapter's vdb), with a
filesystem on it. Several files go in /tmp, which Ubuntu empties at boot,
so do the tasks without a reboot and run le-lab check before you clean up.
Tasks
- Copy
/etc/sshinto/tmp/srcand mirror/tmp/src/to/tmp/dst/with rsync. Add a file/tmp/src/ssh/new.txtand delete/tmp/src/ssh/moduli, try a dry run, then mirror again so that/tmp/dstmatches. Finally, copy/tmp/src(no trailing slash) into/tmp/dst2/, and see where it lands. - As
alex, set up SSH keys so that alex can log in to the peer ([email protected]) without a password, then pull a copy of the peer's/etc/into/tmp/other-etc/with rsync. Files only root can read are skipped with "Permission denied". - Image
/dev/loop40into/tmp/vdb.imgwith dd and compare the two withcmp. Keep the image until you've runle-lab check.
Hints
rsync -av SRC/ DST/,rsync -avn --delete,rsync -a SRC DST/.sudo -iu alex,ssh-keygen. The peer shares alex's home directory, so adding the public key to~/.ssh/authorized_keysis enough (ssh-copy-idneeds a password login, which may be turned off).rsync -a [email protected]:/etc/ /tmp/other-etc/.dd if=DISK of=IMAGE bs=4M status=progress,cmp DISK IMAGE && echo identical.