17
Linux Systems Security Backup and Change Management NETS1028 - Fall 2016

Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

Linux Systems SecurityBackup and Change Management

NETS1028 - Fall 2016

Page 2: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

Backup• Security breaches can cast doubt on entire installations or

render them corrupt

• Files or entire systems may have to be recovered from backup

• Many tools are available to help with this task in Linux

• Two of the more commonly used ones are rsync and duplicity

https://en.wikipedia.org/wiki/Rsync

http://duplicity.nongnu.org/features.html

Page 3: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

Legacy Tools

• cp is the original way to make a copy of a file, many limitations

• cpio, tar are archival tools created to copy files to backup media (tape by default) - satisfactory for years but they make it cumbersome to manage backup media

• Various software packages provide frontends to these tools in order to make backup/restore easier to manage and more robust

Page 4: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

Rsync

• Rsync has a command line interface which resembles a smart cp, and provides a base for many backup software packages with GUIs

• Can preserve special files such as links and devices

• Can copy to or from local or remote destinations

• Provides standby device capability by synchronizing data stores

Page 5: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

Rsync

• Can compress data in transit to save bandwidth

• It only sends changed data when source file is not compressed or encrypted, otherwise entire file is transmitted

• Can use ssh to encrypt remote backup transfers without requiring encryption of backup storage

• Lighter on bandwidth, heavier on cpu and memory

• Requires rsync be available at both ends of the connection if used over the network

Page 6: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

Rsync Examples• Simple local archive of user data rsync -ahv --delete ~/* /backup/usernamersync -ahv --delete --exclude=~/myBackup ~/* ~/myBackup

• Local archive with history date=$(date "+%F-%H-%M") rsync -ahv --link-dest=/backup/current --delete --exclude={/proc/*,/tmp/*,/run/*,/dev/*,/sys/*,/mnt/*,/lost+found,/media/*,/backup} /* /backup/$date && ln -nsf /backup/$date /backup/current

• Remote archive with history date=$(date "+%F-%H-%M") rsync -ahv --link-dest=/backup/current --delete --exclude={/proc/*,/tmp/*,/run/*,/dev/*,/sys/*,/mnt/*,/lost+found,/media/*,/backup} --rsh="ssh -l ssh-login-user" /* rsync-user@host:/backup/$date && ssh user@host ln -nsf /backup/$date /backup/current

Page 7: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

Rsync Exercises• Create a VM for a backup server with a minimum OS and add a drive with

enough space to hold your ubuntu vm backup (probably about 6GB will do), put a filesystem on it and mount it on /backup

• Enable ssh root access to backup server vm either with password, or using keys from your ubuntu machine (modify sshd_config to allow root with password is easiest for the purpose of the lab exercise but not a good idea for production use)

• Run a remote rsync backup from your ubuntu machine to the backup server vm similar to the example from the slide

• Wait a while and rerun the backup to see how much additional data got transferred

• Examine the /backup filesystem on your backup server vm to see what it looks like (use df, ls -l)

Page 8: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

Rsync Restore• Restoration of user data can be done using rsync command to copy data from

backup location

• Can be copied to user staging or live data location

• If you know you are only dealing with regular files, you can even just use cp since the backup filesystem is a synchronized duplicate of the original filesystem

• System recovery requires additional tasks to be performed to deal with the boot block

• Rsync the backup to a new drive

• Install the boot block using GRUB on the new drive

• Install the new drive and boot from it

Page 9: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

Rsync Full System Restore• On the backup server, build an ext4 filesystem on a new disk (e.g. fdisk /dev/sdb and create your

partitions, then mkfs -t ext4 /dev/sdb1) and mount the new filesystem (e.g. mkdir /r ; mount /dev/sdb1 /r)

• rsync -a /wherever-your-backup-is /r

• Use blkid to get the uuid of the new disk and modify /r/etc/fstab to use the new uuid for the root filesystem

• Boot from the distribution media and select rescue mode

• Select the option to rescue a broken system and tell it to rebuild the grub boot loader, then reboot

• If you get dropped to a shell (probably will), do:

mkdir /rmount /dev/sda1 /rmount --bind /proc /r/proc ; mount --bind /dev /r/dev ; mount --bind /sys /r/sys chroot /rgrub-mkconfig > /boot/grub/grub.cfg

• Exit the chroot shell, unmount everything you mounted, and reboot

Page 10: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

Duplicity• Like rsync but does not require duplicity on the receiving backup

host, stores metadata with backup

• Can use many different types of backend storage, including Amazon S3, although they require additional backend packages and configuration effort

• Encrypts tarballs as a storage mechanism, stores deltas in separate tarballs, may have more steps involved in recovery

• Written in python, heavier on bandwidth, lighter on cpu and memory, reimplements ssh in python

• duplicity /what/to/backup sftp://user@host/backup/directory

Page 11: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

Other Backup Solutions

• Many GUI frontends to the rsync, duplicity, and tar cli tools

• Backintime, DejaDup, CronoPete, Timeshift, Duplicati

• Bacula, Amanda

• Mondo Rescue for disaster recovery

Page 12: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

Change Management

Page 13: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

Change Management

• Implementing and maintaining security is a continuous process, these activities cause changes to your systems

• It has been said that problems created when implementing changes cause approximately 3/4 of all outages

• ITIL (Information Technology Information Library) includes change management as part of its service management best practices, ISO 20000 also covers change management

• It involves setting up advisory boards and creating formal processes for implementing changes

Page 14: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

ITIL Information Technology Information Library

• Created by the UK government in the 1980s

• A set of documents describing best practices for service management in the digital world

• Originally 30+ reference books, now 5

• Most recently updated in 2011

• Not the only way to manage change but has ties to ISO 20000 which makes it a good candidate for larger organizations concerned about standards for management

Page 15: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

ITIL Vol. 3, Service Transition

• Volume 3 of ITIL includes change management

• Goals include minimal service disruption, back-out activity reduction, and economical resource usage to accomplish change

• 3 types of change might include rollout, normal change, and urgent/emergency change - organization dependent

• https://en.wikipedia.org/wiki/ITIL#Change_management

Page 16: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

Change Process

• Change requests can be used to document change purpose, justification, impacts, activities, risks, not all parts may be present at the start of the process

• Change advisory board evaluates requests and provides management approval/denial, including funding approval - may also be where activities and risks get defined

• Change activities include tasks to execute, but also describe testing and validation tasks

Page 17: Linux Systems Security - GitHub Pages...Backup • Security breaches can cast doubt on entire installations or render them corrupt • Files or entire systems may have to be recovered

Testing and Validation

• Ideally changes are validated and tested before deployment in production

• Testing may be done in-house, or delegated

• Security patches are often considered tested when released by vendors

• Testing includes verifying the change achieved the stated goals without unexpected impacts - virtual machines are good ways to do testing and validation