Install Ubuntu Packages behind Proxy Server

Posted on

Regarding on installing packages for adding, removing or updating programs, tools or utilities in Ubuntu Linux operating system distribution, there are certain things which is needed to be looked at. Especially since the installation is performed while connecting directly to the internet.

1. The installation process need to be done in ‘root’ mode. To be able to switch in a root mode, below is the command which is needed to be executed :

sudo su -

Below is the output of the above command executed in the bash prompt :

user@hostname:~$ sudo su -
[sudo] password for user:
root@hostname:~#
  1. Execute the installation process as shown below. We are going to install samba for example with the following pattern :
apt-get install utility_program_tool_name
apt-get : tool or utility which is actually a package management command line program, it is used to execute in a command line and it is working with Ubuntu's APT (Advanced Packaging Tool) library. It is used to perform installation of new software packages, removing existing software packages and also upgrading of existing software packages. 
install :  
utility_program_tool_name :

The command is shown as follows :

user@hostname:~# apt-get install samba
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
attr python-dnspython samba-dsdb-modules samba-vfs-modules tdb-tools
Suggested packages:
bind9 bind9utils ctdb ldb-tools smbldap-tools winbind
The following NEW packages will be installed:
attr python-dnspython samba samba-dsdb-modules samba-vfs-modules tdb-tools
0 upgraded, 6 newly installed, 0 to remove and 456 not upgraded.
1 not fully installed or removed.
Need to get 1.502 kB of archives.
After this operation, 14,6 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Err:1 http://us.archive.ubuntu.com/ubuntu xenial/main i386 python-dnspython all 1.12.0-1
401 Unauthorized
Err:2 http://archive.ubuntu.com/ubuntu xenial/main amd64 tdb-tools amd64 1.3.8-2
401 Unauthorized
Err:3 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 samba amd64 2:4.3.9+dfsg-0ubuntu0.16.04.2
401 Unauthorized
Ign:4 http://archive.ubuntu.com/ubuntu xenial/main amd64 attr amd64 1:2.4.47-2
Err:5 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 samba-dsdb-modules amd64 2:4.3.9+dfsg-0ubuntu0.16.04.2
401 Unauthorized
Err:6 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 samba-vfs-modules amd64 2:4.3.9+dfsg-0ubuntu0.16.04.2
401 Unauthorized
Ign:1 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-dnspython all 1.12.0-1
Err:2 http://archive.ubuntu.com/ubuntu xenial/main amd64 tdb-tools amd64 1.3.8-2
401 Unauthorized
Err:4 http://archive.ubuntu.com/ubuntu xenial/main amd64 attr amd64 1:2.4.47-2
401 Unauthorized
Err:1 http://archive.ubuntu.com/ubuntu xenial/main i386 python-dnspython all 1.12.0-1
401 Unauthorized
Err:1 http://archive.ubuntu.com/ubuntu xenial/main i386 python-dnspython all 1.12.0-1
401 Unauthorized
E: Failed to fetch http://xxxxx.xxxxx.xx.xx/?cfru=aHR0cDovL2FyY2hpdmUudWJ1bnR1LmNvbS91YnVudHUvcG9vbC9tYWluL2QvZG5zcHl0aG9uL3B5dGhvbi1kbnNweXRob25fMS4xMi4wLTFfYWxsLmRlYg== 401 Unauthorized
E: Failed to fetch http://xxxxx.xxxxx.xx.xx/?cfru=aHR0cDovL2FyY2hpdmUudWJ1bnR1LmNvbS91YnVudHUvcG9vbC9tYWluL3QvdGRiL3RkYi10b29sc18xLjMuOC0yX2FtZDY0LmRlYg== 401 Unauthorized
E: Failed to fetch http://xxxxx.xxxxx.xx.xx/?cfru=aHR0cDovL3VzLmFyY2hpdmUudWJ1bnR1LmNvbS91YnVudHUvcG9vbC9tYWluL3Mvc2FtYmEvc2FtYmFfNC4zLjklMmJkZnNnLTB1YnVudHUwLjE2LjA0LjJfYW1kNjQuZGVi 401 Unauthorized
E: Failed to fetch http://xxxxx.xxxxx.xx.xx/?cfru=aHR0cDovL2FyY2hpdmUudWJ1bnR1LmNvbS91YnVudHUvcG9vbC9tYWluL2EvYXR0ci9hdHRyXzIuNC40Ny0yX2FtZDY0LmRlYg== 401 Unauthorized
E: Failed to fetch http://xxxxx.xxxxx.xx.xx/?cfru=aHR0cDovL3VzLmFyY2hpdmUudWJ1bnR1LmNvbS91YnVudHUvcG9vbC9tYWluL3Mvc2FtYmEvc2FtYmEtZHNkYi1tb2R1bGVzXzQuMy45JTJiZGZzZy0wdWJ1bnR1MC4xNi4wNC4yX2FtZDY0LmRlYg== 401 Unauthorized
E: Failed to fetch http://xxxxx.xxxxx.xx.xx/?cfru=aHR0cDovL3VzLmFyY2hpdmUudWJ1bnR1LmNvbS91YnVudHUvcG9vbC9tYWluL3Mvc2FtYmEvc2FtYmEtdmZzLW1vZHVsZXNfNC4zLjklMmJkZnNnLTB1YnVudHUwLjE2LjA0LjJfYW1kNjQuZGVi 401 Unauthorized
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
user@hostname:~#

There is an error as shown above which is forbidden for apt-get to run the installation process of samba for an example. It shown with the error message of 401 Unauthorized as clearly specified in the line below :

E: Failed to fetch http://xxxxx.xxxxx.xx.xx/?cfru=aHR0cDovL3VzLmFyY2hpdmUudWJ1bnR1LmNvbS91YnVudHUvcG9vbC9tYWluL3Mvc2FtYmEvc2FtYmEtdmZzLW1vZHVsZXNfNC4zLjklMmJkZnNnLTB1YnVudHUwLjE2LjA0LjJfYW1kNjQuZGVi 401 Unauthorized

3. So, in order to prevent the error message above from happening, since it is already known that the installation process using apt-get is executed behing a network proxy, it is needed to edit file which is going to be used with apt-get tool to connect to the internet so that it can directly install samba from the internet. The file exist in /etc/apt/apt.conf. Below is the content of the file so that it apt-get tool can be used to install directly connected to the internet :

root@hostname:~# vim /etc/apt/apt.conf

Below is the content of the file which is needed to be inserted in order for apt-get to be able to connect via proxy server so that it can aim directly for installation from internet:

Acquire::http::proxy "http://url.proxy.xx.xx:8080/";
Acquire::https::proxy "https://url.proxy.xx.xx:8080/";
Acquire::ftp::proxy "ftp://url.proxy.xx.xx:8080/";
Acquire::socks::proxy "socks://url.proxy.xx.xx:8080/";
The main point is we have to change all of the above connection method which is going to be used by apt-get to install into the URL of the proxy server used to connect to the internet. In this context, the URL is for an example : url.proxy.xx.xx:8080. And in this context there are a definite port used by the proxy server which is 8080. 

4. After finishing to edit the apt-get file configuration as shown above, re-execute the installation command using apt-get command as shown below :

user@hostname:~# apt-get install samba
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
attr python-dnspython samba-dsdb-modules samba-vfs-modules tdb-tools
Suggested packages:
bind9 bind9utils ctdb ldb-tools smbldap-tools winbind
The following NEW packages will be installed:
attr python-dnspython samba samba-dsdb-modules samba-vfs-modules tdb-tools
0 upgraded, 6 newly installed, 0 to remove and 456 not upgraded.
1 not fully installed or removed.
Need to get 1.502 kB of archives.
After this operation, 14,6 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 python-dnspython all 1.12.0-1 [85,2 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 tdb-tools amd64 1.3.8-2 [21,0 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 tdb-tools amd64 1.3.8-2 [21,0 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 tdb-tools amd64 1.3.8-2 [21,0 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 tdb-tools amd64 1.3.8-2 [21,0 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 tdb-tools amd64 1.3.8-2 [21,0 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 tdb-tools amd64 1.3.8-2 [21,0 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 tdb-tools amd64 1.3.8-2 [21,0 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 tdb-tools amd64 1.3.8-2 [21,0 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 tdb-tools amd64 1.3.8-2 [21,0 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 tdb-tools amd64 1.3.8-2 [21,0 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 tdb-tools amd64 1.3.8-2 [21,0 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 samba amd64 2:4.3.9+dfsg-0ubuntu0.16.04.2 [900 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 attr amd64 1:2.4.47-2 [25,5 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 samba-dsdb-modules amd64 2:4.3.9+dfsg-0ubuntu0.16.04.2 [215 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 samba-vfs-modules amd64 2:4.3.9+dfsg-0ubuntu0.16.04.2 [255 kB]
Fetched 1.482 kB in 1min 15s (19,6 kB/s)
Selecting previously unselected package python-dnspython.
(Reading database ... 826665 files and directories currently installed.)
Preparing to unpack .../python-dnspython_1.12.0-1_all.deb ...
Unpacking python-dnspython (1.12.0-1) ...
Selecting previously unselected package tdb-tools.
Preparing to unpack .../tdb-tools_1.3.8-2_amd64.deb ...
Unpacking tdb-tools (1.3.8-2) ...
Selecting previously unselected package samba.
Preparing to unpack .../samba_2%3a4.3.9+dfsg-0ubuntu0.16.04.2_amd64.deb ...
Unpacking samba (2:4.3.9+dfsg-0ubuntu0.16.04.2) ...
Selecting previously unselected package attr.
Preparing to unpack .../attr_1%3a2.4.47-2_amd64.deb ...
Unpacking attr (1:2.4.47-2) ...
Selecting previously unselected package samba-dsdb-modules.
Preparing to unpack .../samba-dsdb-modules_2%3a4.3.9+dfsg-0ubuntu0.16.04.2_amd64.deb ...
Unpacking samba-dsdb-modules (2:4.3.9+dfsg-0ubuntu0.16.04.2) ...
Selecting previously unselected package samba-vfs-modules.
Preparing to unpack .../samba-vfs-modules_2%3a4.3.9+dfsg-0ubuntu0.16.04.2_amd64.deb ...
Unpacking samba-vfs-modules (2:4.3.9+dfsg-0ubuntu0.16.04.2) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for systemd (229-4ubuntu6) ...
Processing triggers for ureadahead (0.100.0-19) ...
ureadahead will be reprofiled on next reboot
Processing triggers for ufw (0.35-0ubuntu2) ...
Setting up redmine (3.2.1-2) ...
Determining localhost credentials from /etc/mysql/debian.cnf: succeeded.
dbconfig-common: writing config to /etc/dbconfig-common/redmine/instances/default.conf
granting access to database redmine_default for redmine/instance@localhost: already exists.
creating database redmine_default: already exists.
dbconfig-common: flushing administrative password
rake aborted!
ActiveRecord::AdapterNotSpecified: 'development' database is not configured. Available: ["production"]
/var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:248:in `resolve_symbol_connection'
/var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:211:in `resolve_connection'
/var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:139:in `resolve'
/var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:169:in `spec'
/var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb:50:in `establish_connection'
/var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:44:in `each'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/base.rb:315:in `<module:ActiveRecord>'
/var/lib/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/base.rb:26:in `<top (required)>'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
/usr/share/redmine/lib/plugins/acts_as_activity_provider/init.rb:2:in `block in <top (required)>'
/usr/share/redmine/config/initializers/00-core_plugins.rb:12:in `eval'
/usr/share/redmine/config/initializers/00-core_plugins.rb:12:in `block in <top (required)>'
/usr/share/redmine/config/initializers/00-core_plugins.rb:2:in `each'
/usr/share/redmine/config/initializers/00-core_plugins.rb:2:in `<top (required)>'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `block in load'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
/var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:652:in `block in load_config_initializer'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/notifications.rb:166:in `instrument'
/var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:651:in `load_config_initializer'
/var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
/var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:615:in `each'
/var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/engine.rb:615:in `block in <class:Engine>'
/var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `instance_exec'
/var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `run'
/var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:55:in `block in run_initializers'
/var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:44:in `each'
/var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:44:in `tsort_each_child'
/var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/initializable.rb:54:in `run_initializers'
/var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/application.rb:352:in `initialize!'
/usr/share/redmine/config/environment.rb:14:in `<top (required)>'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
/var/lib/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
/var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/application.rb:328:in `require_environment!'
/var/lib/gems/2.3.0/gems/railties-4.2.6/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/var/lib/gems/2.3.0/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `load'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `kernel_load'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:24:in `run'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:304:in `exec'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:11:in `start'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/exe/bundle:27:in `block in <top (required)>'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
/var/lib/gems/2.3.0/gems/bundler-1.12.5/exe/bundle:19:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
dpkg: error processing package redmine (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up python-dnspython (1.12.0-1) ...
Setting up tdb-tools (1.3.8-2) ...
update-alternatives: using /usr/bin/tdbbackup.tdbtools to provide /usr/bin/tdbbackup (tdbbackup) in auto mode
Setting up samba (2:4.3.9+dfsg-0ubuntu0.16.04.2) ...
insserv: warning: script 'K01alfresco' missing LSB tags and overrides
insserv: warning: script 'alfresco' missing LSB tags and overrides
insserv: Script nagios is broken: incomplete LSB comment.
insserv: missing `Default-Start:' entry: please add even if empty.
insserv: missing `Default-Stop:' entry: please add even if empty.
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `nagios'
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `nagios'
insserv: warning: script 'K01alfresco' missing LSB tags and overrides
insserv: warning: script 'alfresco' missing LSB tags and overrides
insserv: Script nagios is broken: incomplete LSB comment.
insserv: missing `Default-Start:' entry: please add even if empty.
insserv: missing `Default-Stop:' entry: please add even if empty.
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `nagios'
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `nagios'
insserv: warning: script 'K01alfresco' missing LSB tags and overrides
insserv: warning: script 'alfresco' missing LSB tags and overrides
insserv: Script nagios is broken: incomplete LSB comment.
insserv: missing `Default-Start:' entry: please add even if empty.
insserv: missing `Default-Stop:' entry: please add even if empty.
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `nagios'
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `nagios'
Setting up attr (1:2.4.47-2) ...
Setting up samba-dsdb-modules (2:4.3.9+dfsg-0ubuntu0.16.04.2) ...
Setting up samba-vfs-modules (2:4.3.9+dfsg-0ubuntu0.16.04.2) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for systemd (229-4ubuntu6) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for ufw (0.35-0ubuntu2) ...
Errors were encountered while processing:
redmine
E: Sub-process /usr/bin/dpkg returned an error code (1)
You have new mail in /var/mail/root
root@hostname:~#

The installation of samba has already finished since there isn’t any similar errors showed up.

One thought on “Install Ubuntu Packages behind Proxy Server

Leave a Reply