How To Create yum/dnf Local & Remote Repository With FTP Server On RHEL 8 /CentOS 8

In this tutorial, I will show you the step by step process of how to configure yum/dnf local repository and FTP remote repository on RHEL 8. We will also point a client system to the FTP server to download packages

In one of the tutorials on this website, I explained in details what a yum repository configuration file should contain and the important parameters needed. In this article, I will show you the steps in configuring an FTP based yum remote repository.

I will be using two servers for this scenario.

Server A is the (FTP Server) : HQDEV1, 192.168.170.173

yum local repository and FTP based remote repository will be configured on server A

Server B is the (client) : DRDEV1, 192.168.170.

yum configuration file will be created on this server and it will point to server A


Step By Step Process

Configuring Server A (yum/dnf local repository and FTP Based remote Server)

1. copy the ISO image to your system

you can use fileZilla or any other utility to get the ISO into your system.

If you don’t know how to, watch the video to see how it is done.

2. Mount the ISO

you can create a mount point if you want to

[root@HQDEV1]# mount rhel-8.1-x86_64-dvd.iso /mnt

3. copy the ISO image to any existing directory or create any directory to copy the ISO image to

[root@HQDEV1 ~]# mkdir /iso_files
[root@HQDEV1 ~]# cd /mnt
[root@HQDEV1 mnt]# ls

AppStream  EFI   extra_files.json  images    media.repo               RPM-GPG-KEY-redhat-release
BaseOS     EULA  GPL               isolinux  RPM-GPG-KEY-redhat-beta  TRANS.TBL
[root@HQDEV1 mnt]# cp -va * /iso_files

4. create a repository configuration file with a “.repo” extension

[root@HQDEV1 ~]# vi /etc/yum.repos.d/local.repo
[rhel8_Appstream]
baseurl=file:///iso_files/AppStream
gpgcheck=0
name=Red Hat Ent Linux App_stream
enable=1


[rhel8_BaseOS]
baseurl=file:///iso_files/BaseOS
gpgcheck=0
name=Red Hat Ent Linux BaseOS
enable=1

5. Verify by listing the repositories

[root@HQDEV1 ~]# yum repolist

Updating Subscription Management repositories.

for x86_64 - BaseOS (RPMs)   4,834
rhel8_Appstream                          Red Hat Ent Linux App_stream                            4,817
rhel8_BaseOS                             Red Hat Ent Linux BaseOS                                1,661

Configuring FTP Based remote Repository

1. Now Install the vsftpd package

[root@HQDEV1 ~]# yum install vsftpd

Updating Subscription Management repositories.
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)    3.4 kB/s | 4.5 kB     00:01
Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)       4.9 kB/s | 4.1 kB     00:00
Red Hat CodeReady Linux Builder for R

2. Allow anonymous download in the vsftpd configuration file

[root@HQDEV1 ~]# vi /etc/vsftpd/vsftpd.conf
FTP remote repository on RHEL 8

3. start the vsftpd service

[root@HQDEV1 ~]# systemctl start vsftpd

4. copy the ISO image files to the default document root location (/var/ftp/pub).

[root@HQDEV1]# cp -va /iso_files/* /var/ftp/pub

5. Allow ftp service in the firewall rule

[root@HQDEV1]# firewall-cmd --add-service=http --permanent
[root@HQDEV1]# systemctl restart firewalld

6. If SELinux is enabled and in enforcing mode, Make sure SELinux context are well labelled

[root@HQDEV1]# restorecon -v /var/ftp/pub/iso_files
[root@HQDEV1]# restorecon -R -v /var/ftp/pub/

Creating/configuring yum configuration file on Server B (client)

1. create yum repository file on server B and point to the FTP server

[root@DRDEV1] vim /etc/yum.repos.d/remote.repo
[rhel8_Appstream_remote]
baseurl=ftp://192.168.170.173/pub/iso_files/AppStream
gpgcheck=0
name=Red Hat Ent Linux App_stream remote
enable=1


[rhel8_BaseOS_remote]
baseurl=ftp://192.168.170.173/pub/iso_files/BaseOS
gpgcheck=0
name=Red Hat Ent Linux BaseOS remote
enable=1

IP will be the FTP server IP, or FQDN

2. Verify

[root@DRDEV1 ~]# yum repolist

Updating Subscription Management repositories.

for x86_64 - BaseOS (RPMs)   4,834
rhel8_Appstream                          Red Hat Ent Linux App_stream                            4,817
rhel8_BaseOS                             Red Hat Ent Linux BaseOS                                1,661
[root@HQDEV1 ~]#

Your feedback is welcomed. If you love others, you will share with others

4 Comments

  1. Hi,
    I was asked to configure the URL starting with http://abc.example.com as the new repository for yum, It still not work after I did a gpgcheck=0 and kept giving me error like “No valid repository and cannot user Yum because the system is not subscribed to redhat. How do I configure yum if I keep getting this error?

    • Hello Parajita,
      Did you do enabled=yes? Why shouldn’t it work? It should work if you do your configurations rightly. If you purchased our premium materials, Please send an email to rhcsa8premium@tekneed.com so we can set up a remote session with you and help you.

  2. my /etc/yum.repo.d/local.repo had enabled=yes, gpgcheck=0 ; but it did not work, do we need to check /etc/yum.conf file as well where gpgcheck is usually set to 1 or a Local repo overrides it if we do a gpgcheck=0 there?

Leave a Reply

Your email address will not be published.


*