How to share a local repository using FTP ?
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
vsftpdpackages are installed.# yum install vsftpdNOTE : Make sure repositories or packages are downloaded using DVD or
reposyncfor 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 aspublic_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/repoNote: Default anonymous access root for FTP is
/var/ftpdirectory of the server. Anonymous access root can be changed by modifyinganon_root=/var/ftpin the config file/etc/vsftpd/vsftpd.conf. -
If Firewall is running, add the required ports and then start and enable
vsftpdservice.# firewall-cmd --add-port=21/tcp --permanent # firewall-cmd --reload # systemctl enable vsftpd.service # systemctl start vsftpd.service
On the client systems :
-
Configure a
yumrepo 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=0NOTE:
- Replace
ip_addressto FTP Server's IP address. - The baseurl will be
ftp://<ip_address>/pub/<path>/if default root directory (/var/ftp/pub) is used.
- Replace
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.