Wednesday, 19 August 2015

How to set proxy in Ubuntu using Command Line Interface(CLI)?

Servers such as Ubuntu Server, Fedora Server, VM based servers etc. run without GUI. If the edge of the network requires proxy connection to establish Internet, it has to be done from the CLI. Here are the basic commands to set proxy for Ubuntu.

1. To Check whether proxy is already set:

$echo $http_proxy   (For http proxy)
$echo $https_proxy  (For https proxy)
$echo $ftp_proxy    (For ftp proxy)

2. To set proxy:

$export http_proxy="http://proxyuser:proxypwd@proxy.server.com:port_number/"
$export https_proxy="https://proxyuser:proxypwd@proxy.server.com:port_number/"
$export ftp_proxy="ftp://proxyuser:proxypwd@proxy.server.com:port_number/"

    change proxyuser to your proxy user
    change proxypwd to your proxy password
    change proxy.server.com to the URL of your proxy server
    change port_number to the proxy port configured on your proxy server


Note:
Ubuntu command apt-get does not work after the above setting also. For this, the following steps have to follow:
1. Create a file name 40proxy inside /etc/apt/apt.conf.d/
2. write the following lines(according to the requirement) :

Acquire::http::proxy "http://proxyuser:proxypwd@proxy.server.com:port_number/";
Acquire::https::proxy "https://proxyuser:proxypwd@proxy.server.com:port_number/";
Acquire::ftp::proxy "ftp://proxyuser:proxypwd@proxy.server.com:port_number/";

No comments:

Post a Comment