Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fedora - How to configure an SSH proxy server with Squid

#1
How to configure an SSH proxy server with Squid

<div><p>Sometimes you can’t connect to an SSH server from your current location. Other times, you may want to add an extra layer of security to your SSH connection. In these cases connecting to another SSH server via a proxy server is one way to get through.</p>
<p><a href="http://www.squid-cache.org/">Squid</a> is a full-featured proxy server application that provides caching and proxy services. It’s normally used to help improve response times and reduce network bandwidth by reusing and caching previously requested web pages during browsing. </p>
<p>However for this setup you’ll configure Squid to be used as an SSH proxy server since it’s a robust trusted proxy server that is easy to configure.</p>
<p> <span id="more-31398"></span> </p>
<h2>Installation and configuration</h2>
<p>Install the squid package using <a href="https://fedoramagazine.org/howto-use-sudo/">sudo</a>:</p>
<pre class="wp-block-preformatted">$ sudo dnf install squid -y</pre>
<p>The squid configuration file is quite extensive but there are only a few things we need to configure. Squid uses access control lists to manage connections.</p>
<p>Edit the <em>/etc/squid/squid.conf</em> file to make sure you have the two lines explained below.</p>
<p>First, specify your local IP network. The default configuration file already has a list of the most common ones but you will need to add yours if it’s not there. For example, if your local IP network range is 192.168.1.X, this is how the line would look:</p>
<pre class="wp-block-preformatted">acl localnet src 192.168.1.0/24</pre>
<p>Next, add the SSH port as a safe port by adding the following line:</p>
<pre class="wp-block-preformatted">acl Safe_ports port 22</pre>
<p>Save that file. Now enable and restart the squid proxy service:</p>
<pre class="wp-block-preformatted">$ sudo systemctl enable squid
$ sudo systemctl restart squid</pre>
<p>4.) By default squid proxy listens on port 3128. Configure firewalld to allow for this:</p>
<pre class="wp-block-preformatted">$ sudo firewall-cmd --add-service=squid --perm
$ sudo firewall-cmd --reload</pre>
<h2>Testing the ssh proxy connection</h2>
<p>To connect to a server via ssh through a proxy server we’ll be using netcat. </p>
<p>Install <em>nmap-ncat</em> if it’s not already installed:</p>
<pre class="wp-block-preformatted">$ sudo dnf install nmap-ncat -y</pre>
<p>Here is an example of a standard ssh connection:</p>
<pre class="wp-block-preformatted">$ ssh user@example.com</pre>
<p>Here is how you would connect to that same server using the squid proxy server as a gateway.</p>
<p>This example assumes the squid proxy server’s IP address is 192.168.1.63. You can also use the host-name or the FQDN of the squid proxy server:</p>
<pre class="wp-block-preformatted">$ ssh user@example.com -o "ProxyCommand nc --proxy 192.168.1.63:3128 %h %p"</pre>
<p>Here are the meanings of the options:</p>
<div class="wp-block-group">
<div class="wp-block-group__inner-container">
<ul>
<li><em>ProxyCommand</em> – Tells ssh a proxy command is going to be used.</li>
</ul>
<ul>
<li><em>nc</em> – The command used to establish the connection to the proxy server. This is the netcat command.</li>
</ul>
<ul>
<li><strong><em>%</em></strong><em>h</em> – The placeholder for the proxy server’s host-name or IP address.</li>
</ul>
<ul>
<li><strong><em>%</em></strong><em>p</em><strong><em> </em></strong>– The placeholder for the proxy server’s port number.</li>
</ul>
</div>
</div>
<p>There are many ways to configure an SSH proxy server but this is a simple way to get started.</p>
</div>


https://www.sickgaming.net/blog/2020/07/...ith-squid/
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Fedora - Configure Fedora to practice and compose music xSicKxBot 0 1,103 08-22-2020, 09:44 AM
Last Post: xSicKxBot
  Fedora - How to get MongoDB Server on Fedora xSicKxBot 0 1,086 02-18-2020, 12:41 PM
Last Post: xSicKxBot
  Fedora - Build your own cloud with Fedora 31 and Nextcloud Server xSicKxBot 0 1,103 01-28-2020, 05:00 AM
Last Post: xSicKxBot
  Fedora - How to setup a DNS server with bind xSicKxBot 0 1,087 01-14-2020, 06:50 AM
Last Post: xSicKxBot
  Fedora - How to setup an anonymous FTP download server xSicKxBot 0 1,089 10-23-2019, 10:32 PM
Last Post: xSicKxBot
  Fedora - How to set up a TFTP server on Fedora xSicKxBot 0 1,157 09-11-2019, 05:22 PM
Last Post: xSicKxBot
  Fedora - Fedora job opening: Fedora Community Action and Impact Coordinator (FCAIC) xSicKxBot 0 1,059 07-11-2019, 10:39 AM
Last Post: xSicKxBot
  Fedora - Contribute at the Fedora Test Day for Fedora Modularity xSicKxBot 0 1,153 03-28-2019, 11:12 PM
Last Post: xSicKxBot
  Fedora - How to Build a Netboot Server, Part 4 xSicKxBot 0 1,280 01-14-2019, 02:18 PM
Last Post: xSicKxBot
  Fedora - How to Build a Netboot Server, Part 3 xSicKxBot 0 1,100 12-21-2018, 01:47 PM
Last Post: xSicKxBot

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016