- Linux Proxy Server Settings – Set Proxy For Command Line
- Export Proxy Server Settings
- Test The Proxy Server From The Linux Command-Line
- Unset Linux Proxy Variables
- Automate Proxy Server Settings In Linux
- Lists of Free Public Proxy Servers
- How to set up proxy using http_proxy & https_proxy environment variable in Linux?
- What is Proxy Server?
- Check current proxy configuration status (https_proxy/https_proxy)
- Set up proxy server using http_proxy environment variable
- Set up proxy without username and password
- Set up proxy with username and password
- Set up proxy with domain, username and password
- Special character (@) handling
- Set up proxy permanently using /etc/environment
- Set up proxy permanently using /etc/profile.d
- How To Use Proxy Server To Access Internet at Shell Prompt With http_proxy Variable
- Set http_proxy shell variable on Linux/OS X/Unix bash shell
- How do I setup proxy variable for all users?
- A note about enabling proxy access to a specific user
- How do I use password protected proxy server using various command line options?
- How to Set the http_proxy Variable in Linux
- How to configure proxy settings on Ubuntu 18.04
- Overview
- Ubuntu Desktop Network Settings
- Ubuntu Terminal Proxy Settings
- Single User Temporary Proxy Settings
- Single User Persistent Proxy Settings
- All Users
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
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 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:
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.
Источник
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
Источник
How to Set the http_proxy Variable in Linux
The following article will teach you how to allow your Linux system to use a proxy server for command line tools like wget and yum.
The http_proxy variable tells the system what proxy server it should used to fetch URLs on the command line. This allows you to manually download a file via http, https and ftp and also allows most other command line programs to get files from the internet (for example the yum command to update you Linux system).
To set the http_proxy variable just have to assign a value to it like so:
You must give the value in the URL:PORT format like above. Now if you request a resource from the internet on the command line it will work fine. A simple test would be to fetch our homepage.
After running the above command you should have an index.html file which is our homepage you just downloaded.
If you set the variable like mentioned above it will only work for the current shell. If you close the terminal, log out, or create a new shell (terminal window) the variable will not work. For it to work on all new shells you must export it, or what is known and make it a global variable, like so:
This will still only be useful for all child shells. To make this setting survive a reboot you can put the command in your .bashrc file. This will actually set the variable and export it every time you open a shell.
Or you can manually edit the
/.bashrc file and add the line about with your favorite text editor.
Once you update the bashrc file, you need to source it to load the new file.
Setting it in the
/.bashrc file is only going to work for the one user who’s home directory the .bashrc file resides in. To make this a global variable for all users place it in the /etc/bashrc file.
Источник
How to configure proxy settings on Ubuntu 18.04
Overview
Proxies are commonly found on business networks, but they are increasingly becoming popular for personal use. The following tutorial will show you multiple ways of setting your proxy in Ubuntu 18.04, allowing you to browse the Internet with additional privacy.
This tutorial will cover the following three areas. Use the one the fits your needs.
Desktop: learn how to set your proxy settings from within the desktop.
Terminal: set environment variables for your proxy server when using a terminal or console.
All users: setting the proxy settings for all users on the system.
Ubuntu Desktop Network Settings
To configure your proxy settings in Ubuntu Desktop you need to access Network Settings. Within there you can set a number of parameters, including proxy settings for HTTP traffic, HTTPS traffic, and FTP traffic.
Equally as important as setting your Internet proxy settings is setting Ignore Hosts, to prevent local traffic from going through your proxy server.
To set your proxy in Ubuntu Desktop, do the following:
- Open the Application launcher by clicking the “Show Applications” icon, located at the bottom of the left-hand quick application access bar.
- Type in ‘Settings’
- Click the ‘Settings’ icon.
- From the left-hand navigation, click the Network tab.
Network Settings Configuration Screen
Click the cog icon near the Network Proxy label.
Network settings proxy icon
Ubuntu Proxy Settings Dialog Box
Ubuntu Terminal Proxy Settings
Like every Linux distribution, proxy settings can be set using environment variables. There are a number of variables available to use, ranging from HTTP traffic to FTP traffic.
Proxy settings can be either persistent by setting them in your profile, or non-persistent by setting them from the shell session.
Variable | Description |
---|---|
http_proxy | Proxy server for HTTP Traffic. |
https_proxy | Proxy server for HTTPS traffic |
ftp_proxy | Proxy server for FTP traffic |
no_proxy | Patterns for IP addresses or domain names that shouldn’t use the proxy |
The value for every proxy setting, except for no_proxy, uses the same template. They all require a hostname, but you may optionally specify a proxy server port and your user credentials if required to do so. For example:
Single User Temporary Proxy Settings
You may not always want to force Internet traffic through a proxy. Sometimes you need to override existing settings, and you can do this safely by setting the proxy environment variables from the command line.
The following will set a proxy for HTTP and HTTPS, while preventing local traffic from going through the proxy. Our example proxy server endpoint is my.proxy.server:8080 for HTTP traffic and my.proxy.server:8081 for HTTPS.
- Open a Terminal window where you need proxy access.
- Set and export the HTTP_PROXY variable.
- Set and export the HTTPS_PROXY variable.
- Set and export the NO_PROXY variable to prevent local traffic from being sent to the proxy.
Single User Persistent Proxy Settings
- Open your bash profile file into a text editor.
- Add the following lines, modifying them to match your environment.
- Save your settings.
- The proxy settings will be applied the next time you start a session, by logging into the server or opening a new Terminal window from a Desktop.
- To force apply your new proxy settings in the current Terminal session, execute the source command against your bash profile.
All Users
You will need administrative rights to perform this task. All versions of Ubuntu and Debian have a file called /etc/environment. Within this file, we can set global variables and other such things.
Similar to how you set proxy settings for your own local proxy, we’ll be adding the environment variables to this file. The variables will be set when a new user session is created, which is to say when you log in next.
- Using an administrator account, open /etc/environment into a text editor.
- Add the following lines, modifying them to fit your environment. Username and password may be omitted, if not required.
For example, if you do not need to enter a username or password, and your proxy server is my.proxyserver.net at port 8080, and you do not want local traffic going through the proxy, you would enter the following:
Источник