Download and install ubuntu packages and dependencies on a server without internet connection












4















I'm trying to download all packages and needed dependencies on a server with working internet connection and transfer them on server without internet connection and then install them via apt-get.



I have two solutions to download packages:




  1. apt-get --print-uris --yes install pkgspec | grep ^' | cut -d' -f2 > downloads.list


Is useless because it works only for packages and dependencies that are not downloaded and installed already on a server with working internet connection.




  1. aptitude download '?reverse-depends(package)'


It downloads all packages and dependencies also if you don't need them.



Anyone knows a better solution to download a package and dependencies needed to be installed on a fresh install of Ubuntu server 16.04?



I want to create a script that goes trough a list of packages and downloads all packages and dependencies automatically.



Then I need a solution to use this packages on a offline computer with apt-get. Idea is to create a local apt repository that allows you to use your local packages via apt-get.



So I use this command to create Packages.gz that contains info about all packages that were download in first step.



dpkg-scanpackages . /dev/null | gzip > Packages.gz


Then I add a new source to /etc/apt/sources.list.d/ and run apt-get update.



deb [trusted=yes] file:///tmp/dpkgs /


Now I have a problem that I can for example install apache (still some errors). But if I want to install php I got the following error.



root@ubuntu:~# apt-get install php
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
php : Depends: php7.0 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.


Anyone has a working solution for this problem?
Thanks.










share|improve this question

























  • Did you see this possible duplicate?

    – Pablo Bianchi
    Jan 25 at 3:22
















4















I'm trying to download all packages and needed dependencies on a server with working internet connection and transfer them on server without internet connection and then install them via apt-get.



I have two solutions to download packages:




  1. apt-get --print-uris --yes install pkgspec | grep ^' | cut -d' -f2 > downloads.list


Is useless because it works only for packages and dependencies that are not downloaded and installed already on a server with working internet connection.




  1. aptitude download '?reverse-depends(package)'


It downloads all packages and dependencies also if you don't need them.



Anyone knows a better solution to download a package and dependencies needed to be installed on a fresh install of Ubuntu server 16.04?



I want to create a script that goes trough a list of packages and downloads all packages and dependencies automatically.



Then I need a solution to use this packages on a offline computer with apt-get. Idea is to create a local apt repository that allows you to use your local packages via apt-get.



So I use this command to create Packages.gz that contains info about all packages that were download in first step.



dpkg-scanpackages . /dev/null | gzip > Packages.gz


Then I add a new source to /etc/apt/sources.list.d/ and run apt-get update.



deb [trusted=yes] file:///tmp/dpkgs /


Now I have a problem that I can for example install apache (still some errors). But if I want to install php I got the following error.



root@ubuntu:~# apt-get install php
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
php : Depends: php7.0 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.


Anyone has a working solution for this problem?
Thanks.










share|improve this question

























  • Did you see this possible duplicate?

    – Pablo Bianchi
    Jan 25 at 3:22














4












4








4








I'm trying to download all packages and needed dependencies on a server with working internet connection and transfer them on server without internet connection and then install them via apt-get.



I have two solutions to download packages:




  1. apt-get --print-uris --yes install pkgspec | grep ^' | cut -d' -f2 > downloads.list


Is useless because it works only for packages and dependencies that are not downloaded and installed already on a server with working internet connection.




  1. aptitude download '?reverse-depends(package)'


It downloads all packages and dependencies also if you don't need them.



Anyone knows a better solution to download a package and dependencies needed to be installed on a fresh install of Ubuntu server 16.04?



I want to create a script that goes trough a list of packages and downloads all packages and dependencies automatically.



Then I need a solution to use this packages on a offline computer with apt-get. Idea is to create a local apt repository that allows you to use your local packages via apt-get.



So I use this command to create Packages.gz that contains info about all packages that were download in first step.



dpkg-scanpackages . /dev/null | gzip > Packages.gz


Then I add a new source to /etc/apt/sources.list.d/ and run apt-get update.



deb [trusted=yes] file:///tmp/dpkgs /


Now I have a problem that I can for example install apache (still some errors). But if I want to install php I got the following error.



root@ubuntu:~# apt-get install php
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
php : Depends: php7.0 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.


Anyone has a working solution for this problem?
Thanks.










share|improve this question
















I'm trying to download all packages and needed dependencies on a server with working internet connection and transfer them on server without internet connection and then install them via apt-get.



I have two solutions to download packages:




  1. apt-get --print-uris --yes install pkgspec | grep ^' | cut -d' -f2 > downloads.list


Is useless because it works only for packages and dependencies that are not downloaded and installed already on a server with working internet connection.




  1. aptitude download '?reverse-depends(package)'


It downloads all packages and dependencies also if you don't need them.



Anyone knows a better solution to download a package and dependencies needed to be installed on a fresh install of Ubuntu server 16.04?



I want to create a script that goes trough a list of packages and downloads all packages and dependencies automatically.



Then I need a solution to use this packages on a offline computer with apt-get. Idea is to create a local apt repository that allows you to use your local packages via apt-get.



So I use this command to create Packages.gz that contains info about all packages that were download in first step.



dpkg-scanpackages . /dev/null | gzip > Packages.gz


Then I add a new source to /etc/apt/sources.list.d/ and run apt-get update.



deb [trusted=yes] file:///tmp/dpkgs /


Now I have a problem that I can for example install apache (still some errors). But if I want to install php I got the following error.



root@ubuntu:~# apt-get install php
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
php : Depends: php7.0 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.


Anyone has a working solution for this problem?
Thanks.







package-management offline






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 25 at 3:18









Pablo Bianchi

2,4851532




2,4851532










asked Aug 12 '16 at 11:45









AdrijanAdrijan

2412




2412













  • Did you see this possible duplicate?

    – Pablo Bianchi
    Jan 25 at 3:22



















  • Did you see this possible duplicate?

    – Pablo Bianchi
    Jan 25 at 3:22

















Did you see this possible duplicate?

– Pablo Bianchi
Jan 25 at 3:22





Did you see this possible duplicate?

– Pablo Bianchi
Jan 25 at 3:22










3 Answers
3






active

oldest

votes


















1














Lan Morrison has made an isorespin.sh script that will make an image from commands you give and with an added command can have all the updates to that time on the image and install any apt install you want on the install image it makes. I used it and it works real good.



For more details, see: Customizing Ubuntu ISOs: Documentation and examples of how to use isorespin.sh.






share|improve this answer

































    0














    I have never tried this, so YMMV.



    Check out this and apt-offline.



    They claim to do exactly what you want.






    share|improve this answer































      0














      My recommendation is to do ssh tunnels, I supose you are loging to server with an SSH connection from a machine who has internet connection, hence you can try to use reverse tunnels to have access at least to your desired repos... Please follow these steps:





      1. Log in to your server with the following command:



        ssh -R 127.0.0.1:9800:yourrepo.address:80 youruser@ServerWithoutInternetConnectionAddress



      2. Once logged in your server add the following line to /etc/hosts:



        127.0.0.1 yourrepo.adress



      3. In your repository configuration file in /etc/apt/sources.list or in /etc/apt/sources.list.d/repofile.list modify your repository address by adding used port (I've used 9800, although it can be any port higher than 1023):



        deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial main
        deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial-updates main
        deb [arch=amd64] http://yourrepo.address:9800/ubuntu-java/ xenial main
        deb [arch=amd64] http://yourrepo.address:9800/ubuntu-production/ xenial multiverse



      Now apt-get update and apt-get install should be working. Please consider that you can have as many tunnels as repositories, you only need to change your source port.



      E.g. consider that you have official ubuntu repository in /etc/apt/sources.list and other in /etc/apt/sources.list.d/repofile.listI can use port to 9801 for us.archive.ubuntu.com and port 9800 for /etc/apt/sources.list.d/repofile.list as following:



      /etc/apt/sources.list



      deb http://us.archive.ubuntu.com:9801/ubuntu/ xenial main restricted universe multiverse
      deb-src http://us.archive.ubuntu.com:9801/ubuntu/ xenial main restricted multiverse
      deb http://us.archive.ubuntu.com:9801/ubuntu/ xenial-security main restricted universe multiverse
      deb http://us.archive.ubuntu.com:9801/ubuntu/ xenial-updates main restricted universe multiverse
      deb-src http://us.archive.ubuntu.com:9801/ubuntu/ xenial-security main restricted multiverse
      deb-src http://us.archive.ubuntu.com:9801/ubuntu/ xenial-updates main restricted multiverse


      /etc/apt/sources.list



      deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial main
      deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial-updates main
      deb [arch=amd64] http://yourrepo.address:9800/ubuntu-java/ xenial main
      deb [arch=amd64] http://yourrepo.address:9800/ubuntu-production/ xenial multiverse


      By adding this to /etc/hosts



      127.0.0.1     yourrepo.adress      us.archive.ubuntu.com


      And log in from a machine with internet connection as following:



      ssh -R 127.0.0.1:9800:yourrepo.address:80 -R 127.0.0.1:9801:us.archive.ubuntu.com:80 youruser@ServerWithoutInternetConnectionAddress


      PS: Consider that if your repository needs a key you will need to extract the key (from a machine that has the key apt-key export KEY_ID >> key.asc) and add it using the following command:



      apt-key add key.asc





      share|improve this answer

























        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "89"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f811423%2fdownload-and-install-ubuntu-packages-and-dependencies-on-a-server-without-intern%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        1














        Lan Morrison has made an isorespin.sh script that will make an image from commands you give and with an added command can have all the updates to that time on the image and install any apt install you want on the install image it makes. I used it and it works real good.



        For more details, see: Customizing Ubuntu ISOs: Documentation and examples of how to use isorespin.sh.






        share|improve this answer






























          1














          Lan Morrison has made an isorespin.sh script that will make an image from commands you give and with an added command can have all the updates to that time on the image and install any apt install you want on the install image it makes. I used it and it works real good.



          For more details, see: Customizing Ubuntu ISOs: Documentation and examples of how to use isorespin.sh.






          share|improve this answer




























            1












            1








            1







            Lan Morrison has made an isorespin.sh script that will make an image from commands you give and with an added command can have all the updates to that time on the image and install any apt install you want on the install image it makes. I used it and it works real good.



            For more details, see: Customizing Ubuntu ISOs: Documentation and examples of how to use isorespin.sh.






            share|improve this answer















            Lan Morrison has made an isorespin.sh script that will make an image from commands you give and with an added command can have all the updates to that time on the image and install any apt install you want on the install image it makes. I used it and it works real good.



            For more details, see: Customizing Ubuntu ISOs: Documentation and examples of how to use isorespin.sh.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 13 '18 at 15:51









            kenorb

            4,36513953




            4,36513953










            answered Feb 5 '18 at 12:31









            Raymond DayRaymond Day

            113




            113

























                0














                I have never tried this, so YMMV.



                Check out this and apt-offline.



                They claim to do exactly what you want.






                share|improve this answer




























                  0














                  I have never tried this, so YMMV.



                  Check out this and apt-offline.



                  They claim to do exactly what you want.






                  share|improve this answer


























                    0












                    0








                    0







                    I have never tried this, so YMMV.



                    Check out this and apt-offline.



                    They claim to do exactly what you want.






                    share|improve this answer













                    I have never tried this, so YMMV.



                    Check out this and apt-offline.



                    They claim to do exactly what you want.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Aug 19 '16 at 6:27









                    JoeJoe

                    1,201821




                    1,201821























                        0














                        My recommendation is to do ssh tunnels, I supose you are loging to server with an SSH connection from a machine who has internet connection, hence you can try to use reverse tunnels to have access at least to your desired repos... Please follow these steps:





                        1. Log in to your server with the following command:



                          ssh -R 127.0.0.1:9800:yourrepo.address:80 youruser@ServerWithoutInternetConnectionAddress



                        2. Once logged in your server add the following line to /etc/hosts:



                          127.0.0.1 yourrepo.adress



                        3. In your repository configuration file in /etc/apt/sources.list or in /etc/apt/sources.list.d/repofile.list modify your repository address by adding used port (I've used 9800, although it can be any port higher than 1023):



                          deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial main
                          deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial-updates main
                          deb [arch=amd64] http://yourrepo.address:9800/ubuntu-java/ xenial main
                          deb [arch=amd64] http://yourrepo.address:9800/ubuntu-production/ xenial multiverse



                        Now apt-get update and apt-get install should be working. Please consider that you can have as many tunnels as repositories, you only need to change your source port.



                        E.g. consider that you have official ubuntu repository in /etc/apt/sources.list and other in /etc/apt/sources.list.d/repofile.listI can use port to 9801 for us.archive.ubuntu.com and port 9800 for /etc/apt/sources.list.d/repofile.list as following:



                        /etc/apt/sources.list



                        deb http://us.archive.ubuntu.com:9801/ubuntu/ xenial main restricted universe multiverse
                        deb-src http://us.archive.ubuntu.com:9801/ubuntu/ xenial main restricted multiverse
                        deb http://us.archive.ubuntu.com:9801/ubuntu/ xenial-security main restricted universe multiverse
                        deb http://us.archive.ubuntu.com:9801/ubuntu/ xenial-updates main restricted universe multiverse
                        deb-src http://us.archive.ubuntu.com:9801/ubuntu/ xenial-security main restricted multiverse
                        deb-src http://us.archive.ubuntu.com:9801/ubuntu/ xenial-updates main restricted multiverse


                        /etc/apt/sources.list



                        deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial main
                        deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial-updates main
                        deb [arch=amd64] http://yourrepo.address:9800/ubuntu-java/ xenial main
                        deb [arch=amd64] http://yourrepo.address:9800/ubuntu-production/ xenial multiverse


                        By adding this to /etc/hosts



                        127.0.0.1     yourrepo.adress      us.archive.ubuntu.com


                        And log in from a machine with internet connection as following:



                        ssh -R 127.0.0.1:9800:yourrepo.address:80 -R 127.0.0.1:9801:us.archive.ubuntu.com:80 youruser@ServerWithoutInternetConnectionAddress


                        PS: Consider that if your repository needs a key you will need to extract the key (from a machine that has the key apt-key export KEY_ID >> key.asc) and add it using the following command:



                        apt-key add key.asc





                        share|improve this answer






























                          0














                          My recommendation is to do ssh tunnels, I supose you are loging to server with an SSH connection from a machine who has internet connection, hence you can try to use reverse tunnels to have access at least to your desired repos... Please follow these steps:





                          1. Log in to your server with the following command:



                            ssh -R 127.0.0.1:9800:yourrepo.address:80 youruser@ServerWithoutInternetConnectionAddress



                          2. Once logged in your server add the following line to /etc/hosts:



                            127.0.0.1 yourrepo.adress



                          3. In your repository configuration file in /etc/apt/sources.list or in /etc/apt/sources.list.d/repofile.list modify your repository address by adding used port (I've used 9800, although it can be any port higher than 1023):



                            deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial main
                            deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial-updates main
                            deb [arch=amd64] http://yourrepo.address:9800/ubuntu-java/ xenial main
                            deb [arch=amd64] http://yourrepo.address:9800/ubuntu-production/ xenial multiverse



                          Now apt-get update and apt-get install should be working. Please consider that you can have as many tunnels as repositories, you only need to change your source port.



                          E.g. consider that you have official ubuntu repository in /etc/apt/sources.list and other in /etc/apt/sources.list.d/repofile.listI can use port to 9801 for us.archive.ubuntu.com and port 9800 for /etc/apt/sources.list.d/repofile.list as following:



                          /etc/apt/sources.list



                          deb http://us.archive.ubuntu.com:9801/ubuntu/ xenial main restricted universe multiverse
                          deb-src http://us.archive.ubuntu.com:9801/ubuntu/ xenial main restricted multiverse
                          deb http://us.archive.ubuntu.com:9801/ubuntu/ xenial-security main restricted universe multiverse
                          deb http://us.archive.ubuntu.com:9801/ubuntu/ xenial-updates main restricted universe multiverse
                          deb-src http://us.archive.ubuntu.com:9801/ubuntu/ xenial-security main restricted multiverse
                          deb-src http://us.archive.ubuntu.com:9801/ubuntu/ xenial-updates main restricted multiverse


                          /etc/apt/sources.list



                          deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial main
                          deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial-updates main
                          deb [arch=amd64] http://yourrepo.address:9800/ubuntu-java/ xenial main
                          deb [arch=amd64] http://yourrepo.address:9800/ubuntu-production/ xenial multiverse


                          By adding this to /etc/hosts



                          127.0.0.1     yourrepo.adress      us.archive.ubuntu.com


                          And log in from a machine with internet connection as following:



                          ssh -R 127.0.0.1:9800:yourrepo.address:80 -R 127.0.0.1:9801:us.archive.ubuntu.com:80 youruser@ServerWithoutInternetConnectionAddress


                          PS: Consider that if your repository needs a key you will need to extract the key (from a machine that has the key apt-key export KEY_ID >> key.asc) and add it using the following command:



                          apt-key add key.asc





                          share|improve this answer




























                            0












                            0








                            0







                            My recommendation is to do ssh tunnels, I supose you are loging to server with an SSH connection from a machine who has internet connection, hence you can try to use reverse tunnels to have access at least to your desired repos... Please follow these steps:





                            1. Log in to your server with the following command:



                              ssh -R 127.0.0.1:9800:yourrepo.address:80 youruser@ServerWithoutInternetConnectionAddress



                            2. Once logged in your server add the following line to /etc/hosts:



                              127.0.0.1 yourrepo.adress



                            3. In your repository configuration file in /etc/apt/sources.list or in /etc/apt/sources.list.d/repofile.list modify your repository address by adding used port (I've used 9800, although it can be any port higher than 1023):



                              deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial main
                              deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial-updates main
                              deb [arch=amd64] http://yourrepo.address:9800/ubuntu-java/ xenial main
                              deb [arch=amd64] http://yourrepo.address:9800/ubuntu-production/ xenial multiverse



                            Now apt-get update and apt-get install should be working. Please consider that you can have as many tunnels as repositories, you only need to change your source port.



                            E.g. consider that you have official ubuntu repository in /etc/apt/sources.list and other in /etc/apt/sources.list.d/repofile.listI can use port to 9801 for us.archive.ubuntu.com and port 9800 for /etc/apt/sources.list.d/repofile.list as following:



                            /etc/apt/sources.list



                            deb http://us.archive.ubuntu.com:9801/ubuntu/ xenial main restricted universe multiverse
                            deb-src http://us.archive.ubuntu.com:9801/ubuntu/ xenial main restricted multiverse
                            deb http://us.archive.ubuntu.com:9801/ubuntu/ xenial-security main restricted universe multiverse
                            deb http://us.archive.ubuntu.com:9801/ubuntu/ xenial-updates main restricted universe multiverse
                            deb-src http://us.archive.ubuntu.com:9801/ubuntu/ xenial-security main restricted multiverse
                            deb-src http://us.archive.ubuntu.com:9801/ubuntu/ xenial-updates main restricted multiverse


                            /etc/apt/sources.list



                            deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial main
                            deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial-updates main
                            deb [arch=amd64] http://yourrepo.address:9800/ubuntu-java/ xenial main
                            deb [arch=amd64] http://yourrepo.address:9800/ubuntu-production/ xenial multiverse


                            By adding this to /etc/hosts



                            127.0.0.1     yourrepo.adress      us.archive.ubuntu.com


                            And log in from a machine with internet connection as following:



                            ssh -R 127.0.0.1:9800:yourrepo.address:80 -R 127.0.0.1:9801:us.archive.ubuntu.com:80 youruser@ServerWithoutInternetConnectionAddress


                            PS: Consider that if your repository needs a key you will need to extract the key (from a machine that has the key apt-key export KEY_ID >> key.asc) and add it using the following command:



                            apt-key add key.asc





                            share|improve this answer















                            My recommendation is to do ssh tunnels, I supose you are loging to server with an SSH connection from a machine who has internet connection, hence you can try to use reverse tunnels to have access at least to your desired repos... Please follow these steps:





                            1. Log in to your server with the following command:



                              ssh -R 127.0.0.1:9800:yourrepo.address:80 youruser@ServerWithoutInternetConnectionAddress



                            2. Once logged in your server add the following line to /etc/hosts:



                              127.0.0.1 yourrepo.adress



                            3. In your repository configuration file in /etc/apt/sources.list or in /etc/apt/sources.list.d/repofile.list modify your repository address by adding used port (I've used 9800, although it can be any port higher than 1023):



                              deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial main
                              deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial-updates main
                              deb [arch=amd64] http://yourrepo.address:9800/ubuntu-java/ xenial main
                              deb [arch=amd64] http://yourrepo.address:9800/ubuntu-production/ xenial multiverse



                            Now apt-get update and apt-get install should be working. Please consider that you can have as many tunnels as repositories, you only need to change your source port.



                            E.g. consider that you have official ubuntu repository in /etc/apt/sources.list and other in /etc/apt/sources.list.d/repofile.listI can use port to 9801 for us.archive.ubuntu.com and port 9800 for /etc/apt/sources.list.d/repofile.list as following:



                            /etc/apt/sources.list



                            deb http://us.archive.ubuntu.com:9801/ubuntu/ xenial main restricted universe multiverse
                            deb-src http://us.archive.ubuntu.com:9801/ubuntu/ xenial main restricted multiverse
                            deb http://us.archive.ubuntu.com:9801/ubuntu/ xenial-security main restricted universe multiverse
                            deb http://us.archive.ubuntu.com:9801/ubuntu/ xenial-updates main restricted universe multiverse
                            deb-src http://us.archive.ubuntu.com:9801/ubuntu/ xenial-security main restricted multiverse
                            deb-src http://us.archive.ubuntu.com:9801/ubuntu/ xenial-updates main restricted multiverse


                            /etc/apt/sources.list



                            deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial main
                            deb [arch=amd64] http://yourrepo.address:9800/ubuntu-mirror/ xenial-updates main
                            deb [arch=amd64] http://yourrepo.address:9800/ubuntu-java/ xenial main
                            deb [arch=amd64] http://yourrepo.address:9800/ubuntu-production/ xenial multiverse


                            By adding this to /etc/hosts



                            127.0.0.1     yourrepo.adress      us.archive.ubuntu.com


                            And log in from a machine with internet connection as following:



                            ssh -R 127.0.0.1:9800:yourrepo.address:80 -R 127.0.0.1:9801:us.archive.ubuntu.com:80 youruser@ServerWithoutInternetConnectionAddress


                            PS: Consider that if your repository needs a key you will need to extract the key (from a machine that has the key apt-key export KEY_ID >> key.asc) and add it using the following command:



                            apt-key add key.asc






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jan 25 at 3:21









                            Pablo Bianchi

                            2,4851532




                            2,4851532










                            answered Feb 5 '18 at 11:52









                            Alvaro NiñoAlvaro Niño

                            2487




                            2487






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Ask Ubuntu!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f811423%2fdownload-and-install-ubuntu-packages-and-dependencies-on-a-server-without-intern%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                數位音樂下載

                                格利澤436b

                                When can things happen in Etherscan, such as the picture below?