Skip to content

Installing Packages to a Linux Server Without Internet Access

Occasionally you can find a situation where you have a network admin server in a restricted customer environment or in some other offline environment. I came accross to this a while ago and I followed this procedure to install some essential network tools. Server in my case was RedHat 7.5, but process is similar to any distribution.

To begin with, I built an identical server to my own VM environment - if you need a RedHat server with licenses, check their Developer portal :-)

Only requirement is that you are able to transfer files between your online server and your offline server - this may be tricky and in very restricted environments, might need so physical disk too. In my case I was luckily able to transfer the files through a Citrix RDP session.

In the code examples I have two servers: source is my online VM and target is the offline server.

In my case I needed to run some Python36 scripts, so I can find the packages I'm looking for using yum search


[root@source ~]# yum search python36
Loaded plugins: product-id, search-disabled-repos, subscription-manager
=======================================================================
N/S matched: python36
=======================================================================
rh-python36.x86_64 : Package that installs rh-python36
rh-python36-runtime.x86_64 : Package that handles rh-python36 Software Collection.
rh-python36-scldevel.x86_64 : Package shipping development files for rh-python36
rh-python36-PyYAML.x86_64 : YAML parser and emitter for Python
rh-python36-babel.noarch : Tools for internationalizing Python applications
rh-python36-mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
rh-python36-numpy.x86_64 : A fast multidimensional array facility for Python
rh-python36-numpy-f2py.x86_64 : f2py for numpy
rh-python36-python.x86_64 : Version 3 of the Python programming language aka Python 3000
rh-python36-python-PyMySQL.noarch : Pure-Python MySQL client library
rh-python36-python-babel.noarch : Library for internationalizing Python applications
rh-python36-python-bson.x86_64 : Python bson library
rh-python36-python-coverage.x86_64 : Code coverage testing module for Python
rh-python36-python-debug.x86_64 : Debug version of the Python 3 runtime
rh-python36-python-devel.x86_64 : Libraries and header files needed for Python 3 development
rh-python36-python-docutils.noarch : System for processing plaintext documentation
rh-python36-python-jinja2.noarch : General purpose template engine
rh-python36-python-libs.x86_64 : Python 3 runtime libraries
rh-python36-python-markupsafe.x86_64 : Implements a XML/HTML/XHTML Markup safe string for Python
rh-python36-python-nose.noarch : Discovery-based unittest extension for Python
rh-python36-python-nose-docs.noarch : Nose Documentation
rh-python36-python-pip.noarch : A tool for installing and managing Python packages
rh-python36-python-psycopg2.x86_64 : A PostgreSQL database adapter for Python
rh-python36-python-psycopg2-doc.x86_64 : Documentation for psycopg python PostgreSQL database adapter
rh-python36-python-pygments.noarch : Syntax highlighting engine written in Python
rh-python36-python-pymongo.x86_64 : Python driver for MongoDB
rh-python36-python-pymongo-doc.x86_64 : Documentation for python-pymongo
rh-python36-python-pymongo-gridfs.x86_64 : Python GridFS driver for MongoDB
rh-python36-python-setuptools.noarch : Easily build and distribute Python packages
rh-python36-python-simplejson.x86_64 : Simple, fast, extensible JSON encoder/decoder for Python
rh-python36-python-six.noarch : Python 2 and 3 compatibility utilities
rh-python36-python-sphinx.noarch : Python documentation generator
rh-python36-python-sphinx-doc.noarch : Documentation for python-sphinx
rh-python36-python-sqlalchemy.x86_64 : Modular and flexible ORM library for python
rh-python36-python-test.x86_64 : The test modules from the main python 3 package
rh-python36-python-tkinter.x86_64 : A GUI toolkit for Python 3
rh-python36-python-tools.x86_64 : A collection of tools included with Python 3
rh-python36-python-virtualenv.noarch : Tool to create isolated Python environments
rh-python36-python-wheel.noarch : A built-package format for Python
rh-python36-scipy.x86_64 : Scipy: Scientific Tools for Python
Name and summary matches only, use "search all" for everything.

Based on the output, I would need the base Python36 file and pip for now:


rh-python36.x86_64
rh-python36-python-pip.noarch

Process can be done in following steps


1) Copy RPM DB from the destination server, so you can download all necessary packages required for that. Use tar to pack it.


[root@target ~]# tar cjf rpm_db.tar.bz2 /var/lib/rpm

2) Move rpm_db.tar.bz2 to your online server, VM on my laptop in my case. After that, create a temp directory and extract RPM DB there.


[root@source ~]# mkdir /tmp/rpm_db/
[root@source ~]# tar xf /tmp/rpm_db.tar.bz2 -C /tmp/rpm_db/

3) Download necessary packages with Yum using --downloadonly option, so that packages will be only downloaded and not installed


[root@source ~]# yum install rh-python36.x86_64 rh-python36-python-pip.noarch --downloadonly --downloaddir /tmp/rpm_db --installroot=/tmp/rpm_db/

There are several dependencies required for target server and yum nicely downloads them all.


Dependencies Resolved
=======================================================================
Package Arch Version Repository Size
=======================================================================
Installing:
rh-python36 x86_64 2.0-1.el7 rhel-server-rhscl-7-rpms 3.3 k
rh-python36-python-pip noarch 9.0.1-2.el7 rhel-server-rhscl-7-rpms 1.7 M
Installing for dependencies:
dwz x86_64 0.11-3.el7 rhel-7-server-rpms 99 k
iso-codes noarch 3.46-2.el7 rhel-7-server-rpms 2.7 M
perl-srpm-macros noarch 1-8.el7 rhel-7-server-rpms 4.7 k
python-srpm-macros noarch 3-32.el7 rhel-7-server-rpms 8.5 k
redhat-rpm-config noarch 9.1.0-88.el7 rhel-7-server-rpms 81 k
rh-python36-python x86_64 3.6.9-2.el7 rhel-server-rhscl-7-rpms 56 k
rh-python36-python-devel x86_64 3.6.9-2.el7 rhel-server-rhscl-7-rpms 842 k
rh-python36-python-libs x86_64 3.6.9-2.el7 rhel-server-rhscl-7-rpms 7.6 M
rh-python36-python-setuptools noarch 36.5.0-1.el7 rhel-server-rhscl-7-rpms 567 k
rh-python36-python-virtualenv noarch 15.1.0-2.el7 rhel-server-rhscl-7-rpms 1.8 M
rh-python36-runtime x86_64 2.0-1.el7 rhel-server-rhscl-7-rpms 1.1 M
scl-utils x86_64 20130529-19.el7 rhel-7-server-rpms 24 k
scl-utils-build x86_64 20130529-19.el7 rhel-server-rhscl-7-rpms 18 k

4) Use tar to pack the installation packages - my target server didn't have bzip2 installed, so I just used tar.


[root@source ~]# ls /tmp/rpm_db/
dwz-0.11-3.el7.x86_64.rpm rh-python36-2.0-1.el7.x86_64.rpm rh-python36-python-virtualenv-15.1.0-2.el7.noarch.rpm
etc rh-python36-python-3.6.9-2.el7.x86_64.rpm rh-python36-runtime-2.0-1.el7.x86_64.rpm
iso-codes-3.46-2.el7.noarch.rpm rh-python36-python-devel-3.6.9-2.el7.x86_64.rpm scl-utils-20130529-19.el7.x86_64.rpm
perl-srpm-macros-1-8.el7.noarch.rpm rh-python36-python-libs-3.6.9-2.el7.x86_64.rpm scl-utils-build-20130529-19.el7.x86_64.rpm
python-srpm-macros-3-32.el7.noarch.rpm rh-python36-python-pip-9.0.1-2.el7.noarch.rpm var
redhat-rpm-config-9.1.0-88.el7.noarch.rpm rh-python36-python-setuptools-36.5.0-1.el7.noarch.rpm

[root@source ~]# tar cvf rpm-updates.tar /tmp/rpm_db/*.rpm

5) Move the files to your target server, unpack them and use yum localinstall to install them!


[root@target ~]# mkdir /tmp/rpms
[root@target ~]# tar xf /tmp/rpm-updates.tar -C /tmp/rpms

[root@target ~]# yum localinstall /tmp/rpms/*.rpm

Remember to remove unnecessary packages from the target production server :-)


[root@target ~]# rm -f /tmp/rpms/*.rpm
[root@target ~]# rmdir /tmp/rmps

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
Form options

Submitted comments will be subject to moderation before being displayed.