Question

My end goal is to turn my Raspberry Pi into a FTP Server. It is connected to the network, but with no internet connection. It seems like this would be extremely easy to accomplish if I could just run the "sudo apt-get install ...." command, but since I have no internet this is not possible.

I downloaded the "ftplib" for python which I think will allow me to connect to and interact with my FTP server once I get it up, but right now I am stuck.

I do not know to much about Linux, or web servers so thank you for your patience in advance.

I think a possible solution would be to download a LAMP package on my computer with internet and then transfer it over to the Raspberry Pi, but I am not sure what kind of path and folder issues I might run into then.

Was it helpful?

Solution

Doing this is never ever clean, and never perfect. But below is what I've done to get it to work at times.

You will need a machine that is similar to the FTP server and from the FTP server you will need to download all packages and dependencies. Typically, from the internet machine you will first run:

sudo apt-get clean 

The above command cleans the /var/cache/apt/archives/ directory so that you can ensure it only contains the package and dependencies you desire. Then execute:

sudo apt-get -d build-dep <package_name>

The -d does a download only and build-dep gets all the dependencies required and drops them into /var/cache/apt/archives/. This is why you at least need a similar build. Sometimes you may even need to do a sudo apt-get remove <package name> if your machine already has the package that your destination server requires.

You then take the data out of that directory and put it on some device to transfer to your FTP server. From there you execute on your target machine:

sudo dpkg -i *.deb

The other thing you can do is use apt offline http://apt-offline.alioth.debian.org/

OTHER TIPS

You'll have to download the packages and it's dependencies. Then place them on the sd card and execute:

cd folder_with_debs
sudo dpkg -i *.deb

Btw, it would be easier in most cases to plug an eth cable into the raspberry pi for short (As you are posting here on SO, you should have access to the internet in general)

This is a really long comment in response to @Inquisitor.

Super helpful answer, by the way; it got me on the right track. I'm going to include a few notes below for anyone interested; please note that all this runaround ended up not working, and I just downloaded the files directly from:

ftp://ftp.us.debian.org/debian/pool/main/t/tk8.5/
ftp://ftp.us.debian.org/debian/pool/main/t/tcl8.5/

But hopefully this will be useful to someone.

I'm installing tk8.5-dev and tcl8.5-dev on the pi. To do this I found:

https://packages.debian.org/wheezy/armhf/tk8.5-dev/download
https://packages.debian.org/wheezy/armhf/tcl8.5-dev/download

I added the repo (deb http://ftp.de.debian.org/debian wheezy main) to /etc/apt/sources.list, then ran sudo apt-get update. On update, it yelled at me with:

GPG error: http://ftp.de.debian.org wheezy Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8B48AD6246925553 NO_PUBKEY 6FB2A1C265FFB764

because I'm not on debian, but I did

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8B48AD6246925553
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6FB2A1C265FFB764

It told me no ultimately trusted keys found. I ran sudo apt-get update again. If you miss a key (like I did originally), it'll tell you There is no public key available for the following key IDs: 6FB2A1C265FFB764. If you still have problems, this might be helpful, or maybe the --allow-unauthenticated flag.

At this point, I ran

sudo apt-get -d build-dep tk8.5-dev_8.5.11-2_armhf.deb tcl8.5-dev_8.5.11-2_armhf.deb

and got

Unable to find a source package for tk8.5-dev_8.5.11-2_armhf.deb

So I added an architecture to dpkg:

sudo dpkg --add-architecture armhf
sudo apt-get update

And apt-get still wasn't able to find the packages. Sooo I gave up and downloaded the files directly. In my case, since I couldn't use build-dep, I downloaded and installed everything listed here for armhf:

https://packages.debian.org/stable/devel/libxss-dev
https://packages.debian.org/stable/devel/libxft-dev
https://packages.debian.org/stable/devel/tk8.5-dev
https://packages.debian.org/stable/devel/tk8.5
https://packages.debian.org/stable/devel/tcl8.5-dev
https://packages.debian.org/stable/devel/tcl8.5

There are more dependencies, so I'll work through those today and edit this answer if I find anything else interesting.

Of course, all good things are chiastic, so I had to undo everything again, since I don't want to install debian armhf packages on my amd64 mint system:

sudo dpkg --remove-architecture armhf
sudo apt-key del 8B48AD6246925553
sudo apt-key del 6FB2A1C265FFB764
sudo apt-get update

And removed deb http://ftp.de.debian.org/debian wheezy main from /etc/apt/sources.list

More sources: http://savvyadmin.com/download-pgp-keys-with-apt-key/

Anyway, I don't know if this counts as an answer, but hopefully it'll be helpful to someone.

sudo dpkg -i ftplib

for a Debian package.

The proper way to do it: apt-offline

The real good way of installing packages on an offline system is to use apt-offline. It as really few dependencies allowing you to install it on the offline system with dpkg -i. Download the deb file on pkgs.org.

Example

# Online is the computer connected to internet
# Offline is the computer disconnected from internet
# ---
# ## Install apt-offline ## 
# Online
apt update
apt install apt-offline
# Offline
#   Download last package from pkgs.org
dpkg -i apt-offline_1.8.*_all.deb


# ## Update System ##
# Offline
apt-offline set --update updates.sig
# Online
apt-offline get updates.sig --bundle updates.zip
# Offline 
apt-offline install updates.zip


# ## Upgrade System ##
# <!> Update must be done before.
# Offline
apt-offline set --upgrade upgrade.sig
# Online
apt-offline get upgrade.sig --bundle upgrades.zip
# Offline 
apt-offline install upgrades.zip
apt upgrade --no-download --fix-missing


# ## Install packages##
# <!> Update must be done before.
# pkg1, pkg2 & pkg3 being the packages you want to install
# Offline 
apt-offline set install.sig --install pkg1 pkg2 pkg3
# Online
apt-offline get install.sig --bundle install.zip
# Offline 
apt-offline install install.zip
apt install pkg1 pkg2 pkg3 --no-download --fix-missing

Important: Do not proceed to the update and upgrade/install at the same time. By doing so the upgrade is performed from the package list already installed on the computer, not after the update.

Important 2: apt-offline install and upgrade are not enough to get the packages installed. The only thing this command do, is to fill up the cache of apt (/var/cache/apt/archives) with the packages. That allows you to proceed with apt install --no-download --fix-missing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top