Search code examples
yumamazon-ami

What is the equivalent of apt-key in yum?


I am following a tutorial that can be found here to set up a headless selenium scraper on an ec2 instance:

https://krbnite.github.io/Driving-Headless-Chrome-with-Selenium-on-AWS-EC2/

The tutorial I am using seems to assume an ubuntu distro whereas the ec2 instance I am using is an AWS AMI. As such apt-get is not available to me and instead I use yum to install things.

The first step of the installation process is the following:

wget -q -O - "https://dl-ssl.google.com/linux/linux_signing_key.pub" | sudo apt-key add -

When I do this I get the following, to be expected error on my AWS AMI instance:

sudo: apt-key: command not found

I was wondering what the equivalent command would be without using apt, apt-get, or apt-key but instead using yum. I have blindly tried the following but they did not work:

wget -q -O - "https://dl-ssl.google.com/linux/linux_signing_key.pub" | sudo yum add -

wget -q -O - "https://dl-ssl.google.com/linux/linux_signing_key.pub" | sudo yum-key add -

Thanks


Solution

  • Below is from an article on Baeldung which I think answers this questions properly:

    Adding a repository in YUM is a manual operation, which consists in creating a file with the .repo extension under the folder /etc/yum.repos.d.

    The file must contain all the information about the custom repository that we are connecting to.

    Let’s try adding the AdoptOpenJDK repository:

    # /etc/yum.repos.d/adoptopenjdk.repo
    [AdoptOpenJDK]
    name=AdoptOpenJDK
    baseurl=http://adoptopenjdk.jfrog.io/adoptopenjdk/rpm/centos/7/$(uname -m)
    enabled=1
    gpgcheck=1
    gpgkey=https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public
    

    In APT, though, things are quite different. The GPG key of the repository must be downloaded and added to the APT keyring with apt-key add:

    wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
    

    Then, at this point, the repository can be added through add-apt-repository –yes followed by the URL:

    add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
    

    Contrary to YUM, all the repositories are saved in a single file, /etc/apt/sources.list.