Linux set https proxy

How to set up proxy using http_proxy & https_proxy environment variable in Linux?

Table of Contents

In this article I will share the steps to set up proxy server using https_proxy and https_proxy environment variable.

What is Proxy Server?

A proxy server is a dedicated computer or a software system running on a computer that acts as an intermediary between an endpoint device, such as a computer, and another server from which a user or client is requesting a service. The proxy server may exist in the same machine as a firewall server or it may be on a separate server, which forwards requests through the firewall.

Check current proxy configuration status (https_proxy/https_proxy)

This variable will show if there is a proxy server configured on the system:

If these variables are empty it would mean that there are no proxy servers configured on the system level.

Set up proxy server using http_proxy environment variable

The http_proxy and https_proxy environment variable is used to specify proxy settings to client programs such as curl and wget .

Set up proxy without username and password

Execute the below command with valid SERVER_IP and PORT on the terminal. This will enable proxy configuration for the current session but these values will not be persistent across reboot.

Set up proxy with username and password

You can modify the earlier command to add the username and password value assuming a valid authentication is required to enable the proxy server configuration. But again this command will also enable proxy server for the current session only and will not be persistent across reboots.

Set up proxy with domain, username and password

Assuming you are also required to add domain detail while setting up proxy configuration on your system then use the below command

Special character (@) handling

With more complex and robust handling of special characters in username or password follow How to setup http or https proxy with special characters in username and password

When the username or password uses the @ symbol, add a backslash (\) before the @ — for example:

Set up proxy permanently using /etc/environment

Now as I have highlighted above the above commands will work only for the current active session but will not be available across reboots. So to make these changes persistent define the environment variables in /etc/environment file:

Читайте также:  Windows 10 не обновился directx

Set up proxy permanently using /etc/profile.d

For bash and sh users, add the export line given above into a new file called /etc/profile.d/http_proxy.sh file:

For csh and tcsh users, use the following command to set the http_proxy variable in a new file called /etc/profile.d/http_proxy.csh file:

The extension of these files determines which shell will read them. The commands are not interchangeable.

Lastly I hope the steps from the article to setup proxy using http_proxy and https_proxy environment variable in Linux was helpful. So, let me know your suggestions and feedback using the comment section.

Источник

Linux Proxy Server Settings – Set Proxy For Command Line

To use a proxy on the Linux command-line, you can set the environment variables http_proxy , https_proxy or ftp_proxy , depending on the traffic type.

These proxy server settings are used by the almost all Linux command-line utilities, e.g. ftp , wget , curl , ssh , apt-get , yum and others.

If you don’t know yet which proxy server to use, you can take one from the lists of the free public proxy servers at the end of this article.

Cool Tip: Need to improve security of the Linux system? Encrypt DNS traffic and get the protection from DNS spoofing! Read more →

Export Proxy Server Settings

Set these variables to configure Linux proxy server settings for the command-line tools:

If a proxy server requires authentication, set the proxy variables as follows:

Special Characters: If your password contains special characters, you must replace them with ASCII codes, for example the at sign @ must be replaced by the %40 code, e.g. p@ssword = p%40ssword .

Test The Proxy Server From The Linux Command-Line

First off all it is required to check that the proxy server settings are set in the corresponding proxy variables.

Than it is required to ensure that your public IP address has changed.

Also it would be interesting to measure and compare response time of the remote resources and the Internet speed with and without proxy.

Check the current proxy server settings:

Check your public IP address from the Linux command-line:

Compare the difference in the response time with the configured proxy and without it:

Check the Internet download speed through the proxy:

Unset Linux Proxy Variables

Use the following commands to disable proxy:

Cool Tip: Stay anonymous during port scanning! Use Nmap + Tor + ProxyChains ! Safe and easy penetration testing! Read more →

Automate Proxy Server Settings In Linux

If you use the same proxy server settings for the https , http and ftp traffic, you can use the following commands to set and unset the proxy settings:

If you use a proxy server often, you can create Bash functions as follows (add to your

Now use the setproxy and unsetproxy commands to set and unset Linux proxy server settings.

Lists of Free Public Proxy Servers

WARNING: Free public proxy servers can insert your IP address into the headers of requests or sniff your traffic! Don’t use them to transfer sensitive data and do not expect anonymity!

  • Hide My Ass
  • Proxy Server List
  • Anonymous Public Proxy Servers
  • Daily HTTP Proxies
Читайте также:  Standard windows 10 icons

Cool Tip: Even if you use proxy server, all your DNS queries still go to the name servers of your ISP (Internet Service Provider)! Improve anonymity, by using free public name servers! Read more →

Источник

How To Use Proxy Server To Access Internet at Shell Prompt With http_proxy Variable

I ‘m behind a squid proxy server. How do I access internet via proxy server when I use wget, lynx and other utilities from a shell prompt on a Linux or Unix-like systems?

Linux and UNIX-like systems has environment variable called http_proxy. It allows you to connect text based session and/or applications via the proxy server. All you need is proxy server IP address (URL) and port values. This variable is almost used by all utilities such as elinks, lynx, wget, curl and others commands.

Tutorial details
Difficulty level Easy
Root privileges No
Requirements Linux/Unix shell promot
Est. reading time 2 mintues

Set http_proxy shell variable on Linux/OS X/Unix bash shell

Type the following command to set proxy server:
$ export http_proxy=http://server-ip:port/
$ export http_proxy=http://127.0.0.1:3128/
$ export http_proxy=http://proxy-server.mycorp.com:3128/
If the proxy server requires a username and password then add these to the URL. For example, to include the username foo and the password bar:
$ export http_proxy=http://foo:bar@server-ip:port/
$ export http_proxy=http://foo:bar@127.0.0.1:3128/
$ export http_proxy=http://USERNAME:PASSWORD@proxy-server.mycorp.com:3128/

How do I setup proxy variable for all users?

To setup the proxy environment variable as a global variable, open /etc/profile file:
# vi /etc/profile
Add the following information:
export http_proxy=http://proxy-server.mycorp.com:3128/
OR
export http_proxy=http://USERNAME:PASSOWRD@proxy-server.mycorp.com:3128/
Save and close the file.

A note about enabling proxy access to a specific user

To enable proxy access for a specific user, add the lines user shell profile. For the default bash shell, the profile is the file .bash_profile. For example, enable proxy access for a specifc user called vivek, type:
$ vi $HOME/.bash_profile
OR
# vi /home/vivek/.bash_profile
Append the following line:
export http_proxy=http://USERNAME:PASSOWRD@proxy-server.mycorp.com:3128/
Save and close the file.

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

How do I use password protected proxy server using various command line options?

You can simply use wget command as follows:
$ wget —proxy-user=USERNAME —proxy-password=PASSWORD http://path.to.domain.com/some.html
Lynx command has the following syntax:
$ lynx -pauth=USER:PASSWORD http://domain.com/path/html.file
Curl command has following syntax:
$ curl —proxy-user user:password http://url.com/

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

Как настроить прокси в Ubuntu

С помощью прокси сервера вы можете скрыть свой реальный ip адрес и заставить веб-сайт думать, что вы совсем из другой страны или используете другого провайдера, чем это есть на самом деле. Прокси может использоваться не только для просмотра сайтов интернета, но и для обновления системы, загрузки пакетов через apt и многого другого.

В этой статье мы поговорим о том как выполняется настройка прокси Ubuntu с помощью графического интерфейса или через терминал.

Настройка прокси на Ubuntu через GUI

В Ubuntu можно настроить прокси Ubuntu через стандартное приложение Параметры. Откройте программу, затем перейдите в раздел Сеть и кликните по шестеренке Сетевой прокси:

Здесь надо прописать IP адрес вашего прокси и порт в подходящем поле. Это зависит от типа вашего прокси, например, HTTP/HTTPS или SOCKS:

Если для прокси необходима авторизация, вы можете прописать данные авторизации в поле IP адреса:

логин : пароль @ ip_адрес

Теперь вы можете проверить работает ли новый прокси по всей системе. Например, через терминал:

Настройка прокси в Ubuntu через терминал

Все настройки среды рабочего стола в Ubuntu хранятся в базе данных DConf, в том числе и настройки прокси сервера. Настройки записываются в виде пар ключ значение. Если изменить какой либо параметр из меню настроек системы все изменения сразу же запишутся в DConf. Из командной строки настройками DConf можно управлять с помощью команд gsettings и dconf. Дальше я покажу как настроить прокси в Ubuntu из терминала с помощью gsettings.

Базовое использование gsettings для работы с базой данных Dconf выглядит следующим образом. Для чтения данных используем:

$ gsettings get

А для редактирования:

$ gsettings set

Рассмотрим подробнее как выполняется настройка прокси через консоль Ubuntu. Выполните следующие команды чтобы установить в качестве прокси сервера my.proxy.com:8000

gsettings set org.gnome.system.proxy.http host ‘my.proxy.com’
gsettings set org.gnome.system.proxy.http port 8000
gsettings set org.gnome.system.proxy mode ‘manual’

Если вы хотите использовать HTTPS/FTP прокси то вам нужно выполнить:

gsettings set org.gnome.system.proxy.https host ‘my.proxy.com’
gsettings set org.gnome.system.proxy.https port 8000
gsettings set org.gnome.system.proxy.ftp host ‘my.proxy.com’
gsettings set org.gnome.system.proxy.ftp port 8000

Для использования SOCKS прокси наберите:

gsettings set org.gnome.system.proxy.socks host ‘my.proxy.com’
gsettings set org.gnome.system.proxy.socks port 8000

Все изменения действуют только для текущего пользователя. Если вы хотите установить прокси для всех пользователей запускайте gsettings от суперпользователя добавив перед командой sudo, например:

sudo gsettings set org.gnome.system.proxy.http host ‘my.proxy.com’
sudo gsettings set org.gnome.system.proxy.http port 8000
sudo gsettings set org.gnome.system.proxy mode ‘manual’

Если вы используете автоматическую настройку прокси можете выполнить следующие команды:

gsettings set org.gnome.system.proxy mode ‘auto’
gsettings set org.gnome.system.proxy autoconfig-url http://my.proxy.com/autoproxy.pac

Для того чтобы удалить прежние настройки прокси и работать напрямую выполните:

gsettings set org.gnome.system.proxy mode ‘none’

Чтобы прописать прокси в Ubuntu с авторизацией, записывайте в поле host логин и пароль в том же формате, который предложен для настройки в графическом интерфейсе.

Утилита apt тоже умеет работать с глобальным прокси, настроенным как описано выше, однако вы можете настроить для неё прокси отдельно через конфигурационный файл /etc/apt/apt.conf. Для этого добавьте в этот одну из строк для активации нужного типа прокси:

sudo vi /etc/apt/apt.conf

Acquire::http::proxy «логин:пароль@ip_адрес:порт/»;
Acquire::https::proxy «логин:пароль@ip_адрес:порт/»;

И непосредственно для активации прокси:

Acquire. Proxy «true»;

После этого пакетный менеджер apt будет использовать свой отдельный прокси для обновления Ubuntu.

Выводы

В этой небольшой статье мы поговорили о том, как выполняется настройка прокси Ubuntu. Как видите, это совсем не сложно. Если вы хотите зайти с другой стороны и вам нужно настроить прокси сервер, смотрите статью о том как установить squid в Ubuntu.

Источник

Читайте также:  Как правильно удалить драйвер принтера windows 10
Оцените статью