
In this article, we will show you how to enable proxy settings for yum command on CentOS 7. Yum is a package management tool that works with RPM packages. It is available on RedHat Enterprise Linux, CentOS, and older versions of Fedora, and it is the most convenient way to handle OS packages and their dependencies on these operating systems.
When a server can only be accessed through proxy servers, you need to configure yum to use a proxy server so you can install a RPM package, or update the currently installed yum packages.
To configure a proxy server so the system user can access and use yum commands is a fairly easy and straight-to-the-point task, and it shouldn’t take more than 5 minutes to configure it. Let’s get started.
Table of Contents
1. Configure proxy settings
Edit the ‘/etc/yum.conf’ yum configuration file and specify the proxy settings in the main section e.g.:
Where:
- proxy is the Proxy server URL (domain name or IP address) that yum should use including the TCP port number. In this example, proxysever.yourdomain.com is the URL of the proxy server. Do not forget to change 3128 with the actual port number of the proxy server.
- proxy_username is the proxy server username to use for the proxy URL. If this is unset it inherits it from the global setting.
- proxy_password is the proxy server password to use for the proxy URL. If this is unset it inherits it from the global setting.
Make sure to use a strong password for the proxy password. Use a password that is not the same as any other system user password, especially the root user password.
Please note that all users should have read access to /etc/yum.conf file so they can connect to the proxy server with those details when using yum commands.
2. Enable proxy access for a specific system user only
If for some reason you want to enable proxy access only for a specific system user, you need to add these lines to the user’s shell profile:
If the user is using the default bash shell, the user profile should be set in ~/.bash_profile file. The settings we used in this example should enable yum to use the proxy server proxysever.yourdomain.com, connecting to port 3128.
If the proxy server requires a username and password, edit the user’s shell profile and add the username and password to the URL of the proxy server:
Do not forget to replace rhproxy, D5znQs4P8Rmtw, proxysever.yourdomain.com and 3128 with the actual proxy username, proxy user password, proxy URL and the port number of the proxy server respectively.
3. Test the settings
In order to check if proxy settings are configured properly, run some yum command, for example, try to use:
The output of this command will show you a list with details of all available packages named dovecot:
Congratulations. You have successfully configured proxy server for yum command on CentOS 7.
Of course, you don’t have to enable proxy settings for yum command on CentOS 7, if you use one of our Managed CentOS VPS Hosting Solutions, in which case you can simply ask our expert Linux admins to configure the use of a proxy server so you can use yum command for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on how to enable proxy settings for yum command on CentOS 7, please share it with your friends on social networks or simply leave a reply below. Thanks.