Bookmark this page

Enabling Yum Software Repositories

Objectives

After completing this section, you should be able to enable and disable use of Red Hat or third-party Yum repositories by a server.

Enabling Red Hat software repositories

Registering a system to the subscription management service automatically configures access to software repositories based on the attached subscriptions. To view all available repositories:

[user@host ~]$ yum repolist all
...output omitted...
rhel-8-for-x86_64-appstream-debug-rpms   ... AppStream (Debug RPMs)  disabled
rhel-8-for-x86_64-appstream-rpms         ... AppStream (RPMs)        enabled: 5,045
rhel-8-for-x86_64-appstream-source-rpms  ... AppStream (Source RPMs) disabled
rhel-8-for-x86_64-baseos-debug-rpms      ... BaseOS (Debug RPMs)     enabled: 2,270
rhel-8-for-x86_64-baseos-rpms            ... BaseOS (RPMs)           enabled: 1,963
...output omitted...

The yum config-manager command can be used to enable or disable repositories. To enable a repository, the command sets the enabled parameter to 1. For example, the following command enables the rhel-8-server-debug-rpms repository:

[user@host ~]$ yum config-manager --enable rhel-8-server-debug-rpms
Updating Subscription Management repositories.
============= repo: rhel-8-for-x86_64-baseos-debug-rpms ============
[rhel-8-for-x86_64-baseos-debug-rpms]
bandwidth = 0
baseurl = [https://cdn.redhat.com/content/dist/rhel8/8/x86_64/baseos/debug]
cachedir = /var/cache/dnf
cost = 1000
deltarpm = 1
deltarpm_percentage = 75
enabled = 1
...output omitted...

Non-Red Hat sources provide software through third-party repositories, which can be accessed by the yum command from a website, FTP server, or the local file system. For example, Adobe provides some of its software for Linux through a Yum repository. In a Red Hat classroom, the content.example.com classroom server hosts Yum repositories.

To enable support for a new third-party repository, create a file in the /etc/yum.repos.d/ directory. Repository configuration files must end with a .repo extension. The repository definition contains the URL of the repository, a name, whether to use GPG to check the package signatures, and if so, the URL pointing to the trusted GPG key.

Creating Yum Repositories

Create Yum repositories with the yum config-manager command. The following command creates a file named /etc/yum.repos.d/dl.fedoraproject.org_pub_epel_8_Everything_x86_64_.repo with the output shown.

[user@host ~]$ yum config-manager \
--add-repo="https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/"
Adding repo from: https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/

[dl.fedoraproject.org_pub_epel_8_Everything_x86_64_]
name=created by yum config-manager from https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/
baseurl=https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/
enabled=1

Modify this file to provide customized values and location of a GPG key. Keys are stored in various locations on the remote repository site, such as, http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8. Administrators should download the key to a local file rather than allowing yum to retrieve the key from an external source. For example:

[EPEL]
name=EPEL 8
baseurl=https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8

RPM Configuration Packages for Local Repositories

Some repositories provide a configuration file and GPG public key as part of an RPM package that can be downloaded and installed using the yum localinstall command. For example, the volunteer project called Extra Packages for Enterprise Linux (EPEL) provides software not supported by Red Hat but compatible with Red Hat Enterprise Linux.

The following command installs the Red Hat Enterprise Linux 8 EPEL repository package:

[user@host ~]$ rpm --import \
http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8
[user@host ~]$ yum install \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Configuration files often list multiple repository references in a single file. Each repository reference begins with a single-word name in square brackets.

[user@host ~]$ cat /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux $releasever - $basearch
#baseurl=https://download.fedoraproject.org/pub/epel/$releasever/Everything/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8

[epel-debuginfo]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Debug
#baseurl=https://download.fedoraproject.org/pub/epel/$releasever/Everything/$basearch/debug
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Source
#baseurl=https://download.fedoraproject.org/pub/epel/$releasever/Everything/SRPMS
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1

To define a repository, but not search it by default, insert the enabled=0 parameter. Repositories can be enabled and disabled persistently with yum config-manager command or temporarily with yum command options, --enablerepo=PATTERN and --disablerepo=PATTERN.

Warning

Install the RPM GPG key before installing signed packages. This verifies that the packages belong to a key which has been imported. Otherwise, the yum command fails due to a missing key. The --nogpgcheck option can be used to ignore missing GPG keys, but this could cause forged or insecure packages to be installed on the system, potentially compromising its security.

References

yum(1), yum.conf(5), and yum-config-manager(1) man pages

For more information, refer to the Managing software repositories chapter in the Red Hat Enterprise Linux 8 Configuring basic system settings Guide at https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_basic_system_settings/index#managing-software-repositories_managing-software-packages

Revision: rh124-8.2-df5a585