13.07.2015 Views

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

Linux System Administration Recipes A Problem-Solution Approach

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 6 ■ SECURING YOUR SYSTEMSwhere you have this key set up; see recipe 6-1) with one of these keys. You won’t need to use yourpassphrase.Now, log out, and then log back in again. This time, you shouldn’t be challenged for yourpassphrases, because the ssh-agent session will still be running. Again, you should be able to log in tothat suitable machine without typing your passphrase. The ssh-agent session should keep running untilthe next time you reboot.■ Note This means that if you’re away from your computer, even for just a few minutes, then someone withphysical access to your machine will also be able to access any machines with keys managed by keychain/sshagent.Always lock your screen whenever you leave your machine! This is good security practice anyway.This long-term running may be seen as a security issue. If someone managed to log in as you, they’dautomatically be able to use your keys, as well. If you use the --clear option for keychain, then everytime you log in, your passphrases will be cleared, and you will be asked for them again. Substitute thisline for the earlier line 02:02 /usr/bin/keychain --clear ~/.ssh/id_rsa ~/.ssh/id_dsa > /dev/null■ Note The passphrases are cleared when you log in, not when you log out. This feature means that you can setyour cronjobs, and so on, to get the passphrases via ssh-agent, and it won’t matter if you’ve logged out overnight.6-3. Limiting rsync Over sshThere may be circumstances in which you want to be able to allow users to rsync to a server but not tossh into it, but you’d still rather run rsync over ssh (which is a good security practice). In general, it’s abad idea to allow users to log on to servers. Use the AllowUsers directive in /etc/ssh/sshd_config torestrict this:AllowUsersjkemp, manager, adminHowever, let’s say you want to allow users to back up their own laptops to a RAID array or other bigdisk. rsync by default these days runs over ssh, which is great in many obvious ways but means that ifyou restrict ssh login to the machine, rsync won’t work either. You could mount the disk over NFS from agateway machine, but that would mean the user transferring their data over two connections: ssh to thegateway machine and then NFS to the RAID array.There is a solution, however, which works like this:1. ssh is allowed, but only for a subset of users who have asked for backup access,using the AllowUsers directive in /etc/ssh/sshd_config:AllowUsersjkemp, admin, user1, user3138Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!