How to share a local repository using FTP ?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux (RHEL 9/8/7)
  • FTP

Issue

  • How to share local repository within offline/disconnected systems using FTP ?

Resolution

On yum repository server :

  • Make sure that vsftpd packages are installed.

    # yum install vsftpd
    

    NOTE : Make sure repositories or packages are downloaded using DVD or reposync for RHEL 7 and RHEL 8 and 9 respectively.

  • If Selinux is Enforcing, the content inside /var/ftp/pub/ or the directory where Packages and Repodata are kept, should contain selinux context as public_content_t. If selinux context is incorrect, change context with below commands.

    # semanage fcontext -a -t public_content_t "/var/ftp/pub/repo"
    # restorecon -vR /var/ftp/pub/repo
    # ls -ldZ /var/ftp/pub/repo
    drwxr-xr-x. root root system_u:object_r:public_content_t:s0 /var/ftp/pub/repo
    

    Note: Default anonymous access root for FTP is /var/ftp directory of the server. Anonymous access root can be changed by modifying anon_root=/var/ftp in the config file /etc/vsftpd/vsftpd.conf.

  • If Firewall is running, add the required ports and then start and enable vsftpd service.

      # firewall-cmd --add-port=21/tcp --permanent     
      # firewall-cmd --reload
    
      # systemctl enable vsftpd.service  
      # systemctl start vsftpd.service
    

On the client systems :

  • Configure a yum repo file that points to the repository server: (Example of a RHEL 7 local repository)

      /// For RHEL 7 :
      # cat /etc/yum.repos.d/rhel7.repo
      [rhel7-ftp]
      name=Red Hat Enterprise Linux 7
      baseurl=ftp://<ip_address>/pub/rhel-7-server-rpms/
      enabled=1
      gpgcheck=0
    
    
      /// For RHEL 8 and 9
      # cat /etc/yum.repos.d/rhel8.repo
      [BaseOS]
      name=Red Hat Enterprise Linux 8 BaseOS
      baseurl=ftp://<ip_address>/pub/BaseOS/
      enabled=1
      gpgcheck=0
    
      [AppStream]
      name=Red Hat Enterprise Linux 8 AppStream
      baseurl=ftp://<ip_address>/pub/AppStream/
      enabled=1
      gpgcheck=0
    

    NOTE:

    • Replace ip_address to FTP Server's IP address.
    • The baseurl will be ftp://<ip_address>/pub/<path>/ if default root directory (/var/ftp/pub) is used.
SBR
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.