Skip to content

Instantly share code, notes, and snippets.

@Alexis-D
Created May 8, 2019 10:41
Show Gist options
  • Save Alexis-D/380e6b075bdfec800b4905330884618e to your computer and use it in GitHub Desktop.
Save Alexis-D/380e6b075bdfec800b4905330884618e to your computer and use it in GitHub Desktop.
How to install packages on a CentOS/RHEL server w/o internet access

Notes for later, how to install packages (and their deps!) on a server without access to internet? Definitely the 'quick way to do it' not the 'right one'.

$ docker run --rm -it centos:7.6.1810 /bin/bash
# cd
# yumdownloader --resolve nmap-ncat ... # download all required packages and their dependencies
# yum install -y createrepo
# createrepo $PWD
# tar cf repo.tar *

Copy repo.tar to your machine:

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
ca6832d91da4        centos:7.6.1810     "/bin/bash"         43 minutes ago      Up 43 minutes                           xenodochial_nobel
$ docker cp xenodochial_nobel:/root/repo.tar .

Move repo.tar however you can to your server (through jump host, USB, etc).

On target server, as root:

# cd
# tar xf repo.tar
# vim /etc/yum.repos.d/localrepo.repo

Add something like this to localrepoo.repo:

[localrepo]
name=local repo
baseurl=file:///root
enabled=1

And then you can go ahead and install packages with a normal yum install -y nmap-nat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment