<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jeremias Adriano</title>
    <description>The latest articles on DEV Community by Jeremias Adriano (@jeremiasadriano).</description>
    <link>https://dev.to/jeremiasadriano</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1839789%2F27f70326-a508-4b5e-ba1e-d8f17b59bee7.jpg</url>
      <title>DEV Community: Jeremias Adriano</title>
      <link>https://dev.to/jeremiasadriano</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jeremiasadriano"/>
    <language>en</language>
    <item>
      <title>How to Setup Proxy on APT, Docker, and SSH</title>
      <dc:creator>Jeremias Adriano</dc:creator>
      <pubDate>Thu, 25 Jul 2024 20:11:51 +0000</pubDate>
      <link>https://dev.to/jeremiasadriano/how-to-configure-proxy-for-docker-apt-and-ssh-10lf</link>
      <guid>https://dev.to/jeremiasadriano/how-to-configure-proxy-for-docker-apt-and-ssh-10lf</guid>
      <description>&lt;p&gt;Whether for learning, testing, or professional purposes, you might find yourself needing to configure a proxy. In this article, I'll guide you through setting up a proxy for Docker, APT, and SSH. These configurations are crucial to ensure these tools work properly in environments where a proxy is necessary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring Proxy for Docker
&lt;/h2&gt;

&lt;p&gt;To configure Docker to use a proxy, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create a proxy configuration file within Docker's directory:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /etc/systemd/system/docker.service.d
&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/systemd/system/docker.service.d/http-proxy.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add the following lines to the configuration file:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;[&lt;span class="n"&gt;Service&lt;/span&gt;]   
&lt;span class="n"&gt;Environment&lt;/span&gt;=&lt;span class="s2"&gt;"HTTP_PROXY=http://proxy:port"&lt;/span&gt;
&lt;span class="n"&gt;Environment&lt;/span&gt;=&lt;span class="s2"&gt;"HTTPS_PROXY=http://proxy:port"&lt;/span&gt;
&lt;span class="n"&gt;Environment&lt;/span&gt;=&lt;span class="s2"&gt;"NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;strong&gt;HTTP_PROXY&lt;/strong&gt; is used for HTTP connections.&lt;br&gt;
&lt;strong&gt;HTTPS_PROXY&lt;/strong&gt; is used for HTTPS connections.&lt;br&gt;
&lt;strong&gt;NO_PROXY&lt;/strong&gt; specifies addresses that should bypass the proxy (e.g., localhost and 127.0.0.1).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Reload the systemd configuration and restart Docker:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl daemon-reload
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Source: &lt;a href="https://docs.docker.com/config/daemon/proxy/" rel="noopener noreferrer"&gt;Docker Documentation&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring Proxy for APT
&lt;/h2&gt;

&lt;p&gt;To configure APT to use a proxy, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create and edit the proxy configuration file within apt directory:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/apt/apt.conf.d/proxy.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add the following lines to the configuration file:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;Acquire&lt;/span&gt; {
    &lt;span class="n"&gt;HTTP&lt;/span&gt;::&lt;span class="n"&gt;proxy&lt;/span&gt; &lt;span class="s2"&gt;"http://proxy:port"&lt;/span&gt;;
    &lt;span class="n"&gt;HTTPS&lt;/span&gt;::&lt;span class="n"&gt;proxy&lt;/span&gt; &lt;span class="s2"&gt;"http://proxy:port"&lt;/span&gt;;
}
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;strong&gt;HTTP::proxy&lt;/strong&gt; is used for HTTP connections.&lt;br&gt;
&lt;strong&gt;HTTPS::proxy&lt;/strong&gt; is used for HTTPS connections.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Update your system repositories to apply the new proxy settings:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Configuring Proxy for SSH
&lt;/h2&gt;

&lt;p&gt;To configure SSH to use a proxy, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install &lt;code&gt;corkscrew&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;corkscrew
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add the following lines into &lt;code&gt;~/.ssh/config&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;Host&lt;/span&gt; &lt;span class="n"&gt;github&lt;/span&gt;.&lt;span class="n"&gt;com&lt;/span&gt;
    &lt;span class="n"&gt;Hostname&lt;/span&gt; &lt;span class="n"&gt;github&lt;/span&gt;.&lt;span class="n"&gt;com&lt;/span&gt;
    &lt;span class="n"&gt;ServerAliveInterval&lt;/span&gt; &lt;span class="m"&gt;55&lt;/span&gt;
    &lt;span class="n"&gt;ForwardAgent&lt;/span&gt; &lt;span class="n"&gt;yes&lt;/span&gt;
    &lt;span class="n"&gt;ProxyCommand&lt;/span&gt; /&lt;span class="n"&gt;usr&lt;/span&gt;/&lt;span class="n"&gt;bin&lt;/span&gt;/&lt;span class="n"&gt;corkscrew&lt;/span&gt; &lt;span class="n"&gt;YourProxy&lt;/span&gt; &lt;span class="n"&gt;YourPort&lt;/span&gt; %&lt;span class="n"&gt;h&lt;/span&gt; %&lt;span class="n"&gt;p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;strong&gt;Host&lt;/strong&gt; specifies the alias for the SSH connection. Replace &lt;strong&gt;github.com&lt;/strong&gt; with the actual host if different.&lt;br&gt;
&lt;strong&gt;Hostname&lt;/strong&gt; specifies the actual hostname of the server you are connecting to.&lt;br&gt;
&lt;strong&gt;ServerAliveInterval&lt;/strong&gt; ensures that the connection remains active by sending keep-alive messages.&lt;br&gt;
&lt;strong&gt;ForwardAgent&lt;/strong&gt; enables forwarding of the SSH authentication agent to the remote server.&lt;br&gt;
&lt;strong&gt;ProxyCommand&lt;/strong&gt; uses corkscrew to route SSH traffic through the specified proxy. Replace &lt;strong&gt;YourProxy&lt;/strong&gt; and &lt;strong&gt;YourPort&lt;/strong&gt; with the address and port of your proxy server.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Source: &lt;a href="https://gist.github.com/ozbillwang/005bd1dfc597a2f3a00148834ad3e551" rel="noopener noreferrer"&gt;Configure Git to use a proxy (https or SSH+GIT)&lt;/a&gt;&lt;/p&gt;

</description>
      <category>proxy</category>
      <category>docker</category>
      <category>apt</category>
      <category>ssh</category>
    </item>
  </channel>
</rss>
