How do I configure multiple repositories with credentials in yum .repo?

How do I configure multiple repositories with credentials in yum .repo?

AuthorFullName__c
JFrog Support
articleNumber
000001561
ft:sourceType
Salesforce
FirstPublishedDate
2016-10-06T13:35:56Z
lastModifiedDate
2024-03-10T07:48:56Z
VersionNumber
5

You could have multiple repositories configured in your .repo file, or even have multiple .repo files each containing the same baseURL with different credentials.

An example .repo file would look like this:

[user1]

name=user1

baseurl=http://user1:password@localhost:8081/artifactory/yum-local/

gpgcheck=0

enabled=1

 

 

[user2]

name=user2

baseurl=http://user2:password@localhost:8081/artifactory/yum-local/

gpgcheck=0

enabled=1

 

 

YUM aggregates all repository configurations in all .repo files under /etc/yum.repos.d/ so all these repositories will be available to YUM.

When you want to install an RPM package using a specific user’s credentials, you need to disable all repositories and enable only the one relevant to that user, for example:

yum --disablerepo=”*” --enablerepo=”user2” install ant

 

In this example, YUM will search and install (if available) ant from a local yum repository in Artifactory using the credentials provided in the ‘user2’ repository configuration in your .repo file.