[ Team LiB ] |
Recipe 5.20 Sharing root Privileges via Kerberos su5.20.1 ProblemYou want to obtain root privileges in a Kerberos environment. 5.20.2 SolutionTo obtain a root shell: $ ksu To obtain a shell as user barney: $ ksu barney To use another Kerberos principal besides your default for authentication: $ ksu [user] -n principal ... To execute a specific command under the target uid, rather than get a login shell: $ ksu [user] -e command 5.20.3 DiscussionLike the usual Unix su program, ksu allows one account to access another, if the first account is authorized to do so. Unlike su, ksu does authentication using Kerberos rather than plain passwords, and has many more options for authorization. With su, one simply types su <target>. su prompts for the target account's password; if the user supplies the correct password, su starts a shell under the target account's uid (or executes another program supplied on the su command line). With ksu, both authentication and authorization are done differently. 5.20.3.1 Authenticationksu performs authentication via Kerberos, so you must select a Kerberos principal to use. First, ksu tries the default principal indicated in your current Kerberos credentials cache (klist command). If you have no credentials, then it will be the default principal indicated by your Unix account name and the local Kerberos configuration. For example, if your Unix username is fred and the Kerberos realm of your host is FOO.ORG, then your default principal would normally be [email protected] (note that Kerberos realm names are case-sensitive and by convention are in uppercase). If this principal is authorized to access the target account (explained later), then ksu proceeds with it. If not, then it proceeds with the default principal corresponding to the target account. The usual effect of this arrangement is that either your usual Kerberos credentials will allow you access, or you'll be prompted for the target account's Kerberos password, and thus gain access if you know it. You may select a different principal to use with the -n option, e.g.: $ ksu -n [email protected] ... but let's suppose your selected principal is [email protected]. First, ksu authenticates you as [email protected]; specifically, if this host is bar.foo.org, you need a service ticket granted to that principal for host/[email protected]. ksu first attempts to acquire this ticket automatically. If you don't have exactly that ticket, but you do have valid Kerberos credentials for this principal—that is, you have previously done a kinit and acquired a ticket-granting ticket (TGT)—then ksu simply uses it to obtain the required ticket. Failing that, ksu may prompt you for [email protected]'s password. Note two things, however: first, be careful not to type the password over an insecure link (e.g., an unencrypted Telnet session). Second, ksu may be compiled with an option to forbid password authentication, in which case you must have previously acquired appropriate credentials, or the ksu attempt will fail. 5.20.3.2 AuthorizationHaving authenticated you via Kerberos as [email protected], ksu now verifies that this principal is authorized to access the target account, given as the argument to ksu (e.g., ksu barney; the default is the root account). Authorization can happen one of two ways:
Some additional notes:
5.20.4 See Alsoksu(1), and our Kerberos coverage in Chapter 4. |
[ Team LiB ] |