This tutorial aims to install a package on a Ubuntu machine that is not able to connect into the internet, using apt-offline tool. This should be applicable to other Debian distros but it was not validated.
- The offline machine must be accessible by SSH or physically.
- Another Ubuntu machine with the same major release that can access the internet, labelled as online machine from now on.
Unfortunatelly the apt-offline is not a standart tool of Ubuntu, at least not yet. So the installation on the offline machine will be done by download and transfering .deb
installation files. All links are related with bionic release so do not forget to change for the correct version of your distro.
On the online machine it can be installed in a single step:
#online
apt install apt-offline
Now you need to download the .deb
files. Is possible to download through terminal using the wget
command before the url.
- Python3-magic.deb (requirement for the apt-offline)
- Apt-offline.deb
Then, transfer the .deb
files to the offline machine. Next:
- Install the python3-magic:
#offline
dpkg -i python3-magic_0.4.15-1_all.deb
- Install the apt-offline:
#offline
dpkg -i apt-offline_1.8.1_all.deb
After these steps the apt-offline command should be available on the terminal.
Notice that the commands might need root permission (sudo). Execute on the offline machine:
#offline
apt-offline set --update ~/apt-offline.sig
It will generate the .sig
file containning all the information necessary for apt. Transfer the apt-offline.sig
to the online machine home folder, then run on the online machine:
#online
apt-offline get ~/apt-offline.sig --bundle ~/apt-offline.zip
All the data to install on the offline machine is inside the generated apt-offline.zip
file, so transfer it back to the offline home folder and run on the offline machine:
#offline
apt-offline install ~/apt-offline.zip
The offline machine finally has its repositories updated. ππ
As an example, the nginx installation process will be detailed.
On the offline machine, generate the .sig
file that contains the installation request information:
#offline
apt-offline set ~/nginx-info.sig --install-packages nginx
Transfer the nginx-info.sig
to the online machine home folder.
On the online machine, generate the compressed installation package file, based on the .sig
file:
#online
apt-offline get ~/nginx-info.sig --bundle ~/nginx-install.zip
Transfer the .zip
file to the offline machine and update the dependencies locally:
#offline
apt-offline install ~/nginx-install.zip
It is wierd but is necessary to use the apt install
after apt-offline install
to properly install the package, the apt-offline
updates the repository and keep locally everything necessary to install the package. So, at long last, install it:
#offline
apt install nginx
Hopefully, the package is now installed and working fine! ππ
Two options will be listed to send files between the online and offline machines, through SSH: STFP client and SCP.
It mean SSH File Transfer Protocol. There are many programs that use SFTP. The MobaXTerm and FileZilla are good options for Windows. Both have a good interface and will provide a way to upload and download files from the offline and online machine.
In short, is a network version of linux cp command. To see all the options use the man scp
command under the terminal. Examples of SCP command being inside of origin machine:
# Copy a single file to destination
scp originPath/file user@machineIP:destPath/file
# Copy entire folder to destination
scp -r originPath user@machineIP:destPath
# Copy all zip files to destination
scp -r originPath/*.zip user@machineIP:destPath
- @glaucoleme: August 31th, 2020: Adding update system option.