Skip to content

Instantly share code, notes, and snippets.

@dweldon
Created August 3, 2022 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dweldon/b4fadec3994d5ce1ed2c910462812660 to your computer and use it in GitHub Desktop.
Save dweldon/b4fadec3994d5ce1ed2c910462812660 to your computer and use it in GitHub Desktop.
Install mongodb on ubuntu without using apt-key
#!/bin/sh
# https://askubuntu.com/questions/1286545/
# https://www.mongodb.com/docs/v4.4/tutorial/install-mongodb-on-ubuntu/
version='4.2'
gpg_file="mongodb-${version}.gpg"
wget "https://www.mongodb.org/static/pgp/server-${version}.asc"
gpg --no-default-keyring --keyring ./temp-keyring.gpg --import "server-${version}.asc"
gpg --no-default-keyring --keyring ./temp-keyring.gpg --export --output "${gpg_file}"
rm temp-keyring.*
rm "server-${version}.asc"
sudo chown root:root "${gpg_file}"
sudo mv "${gpg_file}" /etc/apt/keyrings/
echo "deb [arch=amd64,arm64 signed-by=/etc/apt/keyrings/${gpg_file}] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/${version} multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-${version}.list
sudo apt-get update
sudo apt-get install -y mongodb-org
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment