Tag Archives: rhsm configuration

How to enable repository using subscription-manager in RHEL

Learn how to enable repository using subscription-manager in RHEL. The article also includes steps to register system with Red Hat, attach subscription and errors along with resolutions.

Enable repository using subscription-manager

In this article, we will walk you through step by step process to enable Red Hat repository in RHEL fresh installed server.

The repository can be enabled using subscription-managercommand like below –

root@kerneltalks # subscription-manager repos --enable rhel-6-server-rhv-4-agent-beta-debug-rpms
Error: 'rhel-6-server-rhv-4-agent-beta-debug-rpms' does not match a valid repository ID. Use "subscription-manager repos --list" to see valid repositories.

You will see the above error when your subscription is not in place. Let’s go through step by step procedure to enable repositories via subscription-manager

Step 1 : Register your system with Red Hat

We are considering you have a freshly installed system and it’s not yet registered with Red Hat. If you have a registered system already then you can ignore this step.

You can check if your system is registered with Red Hat for the subscription using below command –

# subscription-manager version
server type: This system is currently not registered.
subscription management server: Unknown
subscription management rules: Unknown
subscription-manager: 1.18.10-1.el6
python-rhsm: 1.18.6-1.el6

Here, in the first line of output, you can see the system is not registered. So, let’s start with the registering system. You need to use the subscription-managercommand with register switch. You need to use your Red Hat account credentials here.

root@kerneltalks # subscription-manager register
Registering to: subscription.rhsm.redhat.com:443/subscription
Username: admin@kerneltalks.com
Password:
Network error, unable to connect to server. Please see /var/log/rhsm/rhsm.log for more information.

If you are getting above error then your server is not able to reach RedHat. Check internet connection & if you are able to resolve site names. Sometimes even if you are able to ping the subscription server, you will see this error. This might be because you have the proxy server in your environment. In such a case, you need to add its details in file /etc/rhsm/rhsm.conf. Below proxy details should be populated :

# an http proxy server to use
 proxy_hostname =

# port for http proxy server
 proxy_port =

# user name for authenticating to an http proxy, if needed
 proxy_user =

# password for basic http proxy auth, if needed
 proxy_password =

Once you are done, recheck if subscription-manager taken up new proxy details by using below command –

root@kerneltalks # subscription-manager config
[server]
 hostname = [subscription.rhsm.redhat.com]
 insecure = [0]
 port = [443]
 prefix = [/subscription]
 proxy_hostname = [kerneltalksproxy.abc.com]
 proxy_password = [asdf]
 proxy_port = [3456]
 proxy_user = [user2]
 server_timeout = [180]
 ssl_verify_depth = [3]

[rhsm]
 baseurl = [https://cdn.redhat.com]
 ca_cert_dir = [/etc/rhsm/ca/]
 consumercertdir = [/etc/pki/consumer]
 entitlementcertdir = [/etc/pki/entitlement]
 full_refresh_on_yum = [0]
 manage_repos = [1]
 pluginconfdir = [/etc/rhsm/pluginconf.d]
 plugindir = [/usr/share/rhsm-plugins]
 productcertdir = [/etc/pki/product]
 repo_ca_cert = /etc/rhsm/ca/redhat-uep.pem
 report_package_profile = [1]

[rhsmcertd]
 autoattachinterval = [1440]
 certcheckinterval = [240]

[logging]
 default_log_level = [INFO]

[] - Default value in use

Now, try registering your system again.

root@kerneltalks # subscription-manager register
Registering to: subscription.rhsm.redhat.com:443/subscription
Username: admin@kerneltalks.com
Password:
You must first accept Red Hat's Terms and conditions. Please visit https://www.redhat.com/wapps/tnc/termsack?event[]=signIn . You may have to log out of and back into the Customer Portal in order to see the terms.

You will see the above error if you are adding the server to your Red Hat account for the first time. Go to the URL and accept the terms. Come back to the terminal and try again.

root@kerneltalks # subscription-manager register
Registering to: subscription.rhsm.redhat.com:443/subscription
Username: admin@kerneltalks.com
Password:
The system has been registered with ID: xxxxb2-xxxx-xxxx-xxxx-xx8e199xxx

Bingo! The system is registered with Red Hat now. You can again verify it with version switch.

root@kerneltalks # subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 2.0.43-1
subscription management rules: 5.26
subscription-manager: 1.18.10-1.el6
python-rhsm: 1.18.6-1.el6

Step 2: Attach subscription to your server

First, try to list repositories. You won’t be able to list any since we haven’t attached any subscription to our server yet.

root@kerneltalks # subscription-manager repos --list
This system has no repositories available through subscriptions.

As you can see subscription-manager couldn’t found any repositories, you need to attach subscriptions to your server. Once the subscription is attached, subscription-manager will be able to list repositories under it.

To attach subscription, check all available subscriptions for your server with below command –

root@kerneltalks # subscription-manager list --available
+-------------------------------------------+
Available Subscriptions
+-------------------------------------------+
Subscription Name: Red Hat Enterprise Linux for Virtual Datacenters, Standard
Provides: Red Hat Beta
Red Hat Software Collections (for RHEL Server)
Red Hat Enterprise Linux Atomic Host Beta
Oracle Java (for RHEL Server)
Red Hat Enterprise Linux Server
dotNET on RHEL (for RHEL Server)
Red Hat Enterprise Linux Atomic Host
Red Hat Software Collections Beta (for RHEL Server)
Red Hat Developer Tools Beta (for RHEL Server)
Red Hat Developer Toolset (for RHEL Server)
Red Hat Developer Tools (for RHEL Server)
SKU: RH00050
Contract: xxxxxxxx
Pool ID: 8a85f98c6011059f0160110a2ae6000f
Provides Management: Yes
Available: Unlimited
Suggested: 0
Service Level: Standard
Service Type: L1-L3
Subscription Type: Stackable (Temporary)
Ends: 12/01/2018
System Type: Virtual

You will get the list of such subscriptions available for your server. You need to read through what it provides and note down Pool ID of subscriptions that are useful/required for you.

Now, attach subscriptions to your server by using pool ID.

root@kerneltalks # subscription-manager attach --pool=8a85f98c6011059f0160110a2ae6000f
Successfully attached a subscription for: Red Hat Enterprise Linux for Virtual Datacenters, Standard

If you are not sure which one to pick, you can simply attach subscriptions automatically which are best suited for your server with below command –

root@kerneltalks # subscription-manager attach --auto
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status: Subscribed

Move on to the final step to enable repository.

Step 3: Enable repository

Now you will enable repository which is available under your attached subscription.

root@kerneltalks # subscription-manager repos --enable rhel-6-server-rhv-4-agent-beta-debug-rpms
Repository 'rhel-6-server-rhv-4-agent-beta-debug-rpms' is enabled for this system.

That’s it. You are done. You can list repositories with yum command and confirm.