Handling Subscriptions through the Command Line

Subscribing from the Command Line

Subscribing a machine through the command line requires specifying the individual product or subscription to subscribe to, using the --pool option.

[root@server1 ~]# subscription-manager subscribe --pool=XYZ01234567

The options for the subscribe command are listed in .

The ID of the subscription pool for the purchased product must be specified, and this pool ID is listed with the product subscription information, from running the list command:

[root@server1 ~]# subscription-manager list --available
+-------------------------------------------+
    Available Subscriptions
+-------------------------------------------+
ProductName:            RHEL for Physical Servers
ProductId:              MKT-rhel-server
PoolId:                 ff8080812bc382e3012bc3845ca000cb
Quantity:               10
Expires:                2011-09-20

Alternatively, the system can be subscribed to the best-fitting subscriptions, as identified by the subscription service, by using the --auto option (which is analogous to the --autosubscribe option with the register command).

[root@server1 ~]# subscription-manager subscribe --auto

Table 14.4. subscribe Options

Options Description Required
--pool=pool-id Gives the ID for the subscription to subscribe the machine to. Required, unless --auto is used
--auto Automatically subscribes the system to the best-match subscription or subscriptions. Optional
--quantity Subscribes multiple counts of an entitlement to the system. This is used to cover subscriptions that define a count limit, like using two 2-socket server subscriptions to cover a 4-socket machine. Optional

Unsubscribing from the Command Line

A system can be subscribed to multiple subscriptions and products. The system can be unsubscribed from a single subscription or product or from every subscribed product.

Running the unsubscribe command with the --all unsubscribes the system from every product and subscription pool it is currently subscribed to.

[root@server1 ~]# subscription-manager unsubscribe --all

It is also possible to unsubscribe from a single product. Each product has an identifying X.509 certificate installed with it, and the product to unsubscribe from can be identified with the unsubscribe command to remove only that product subscription.

  1. Get the serial number for the product certificate, if you are unsubscribing from a single product. The serial number can be obtained from the cert.pem file or by using the list command. For example:
[root@server1 ~]# subscription-manager list --consumed
+-------------------------------------------+
    Consumed Product Subscriptions
+-------------------------------------------+
ProductName:         High availability (cluster suite)
ContractNumber:      0
SerialNumber:        11287514358600162
Active:              True
Begins:              2010-09-18
Expires:             2011-11-18