{"id":189,"date":"2010-02-13T02:32:09","date_gmt":"2010-02-13T07:32:09","guid":{"rendered":"http:\/\/ebixio.com\/blog\/?p=189"},"modified":"2010-02-13T02:32:09","modified_gmt":"2010-02-13T07:32:09","slug":"tunneling-ssh-option-2","status":"publish","type":"post","link":"http:\/\/ebixio.com\/blog\/2010\/02\/13\/tunneling-ssh-option-2\/","title":{"rendered":"Tunneling ssh &#8211; option 2"},"content":{"rendered":"<p>See the <a href=\"http:\/\/ebixio.com\/blog\/2010\/02\/13\/tunneling-ssh-over-an-http-proxy\/\">previous post<\/a> for an explanation of what we\u2019re trying to accomplish.<\/p>\n<p>This is a diagram of what the setup looks like. The numbers shown are the TCP ports used by the various components.<\/p>\n<p><div id=\"attachment_213\" style=\"width: 468px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/ebixio.com\/blog\/wp-content\/uploads\/2010\/02\/SSH-2.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-213\" src=\"http:\/\/ebixio.com\/blog\/wp-content\/uploads\/2010\/02\/SSH-2.png\" alt=\"SSH through Apache and Stunnel\" title=\"SSH-2\" width=\"458\" height=\"202\" class=\"size-full wp-image-213\" srcset=\"http:\/\/ebixio.com\/blog\/wp-content\/uploads\/2010\/02\/SSH-2.png 458w, http:\/\/ebixio.com\/blog\/wp-content\/uploads\/2010\/02\/SSH-2-300x132.png 300w\" sizes=\"auto, (max-width: 458px) 100vw, 458px\" \/><\/a><p id=\"caption-attachment-213\" class=\"wp-caption-text\">SSH through Apache and Stunnel<\/p><\/div><\/p>\n<p>In the Apache config file:<\/p>\n\n\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&lt;VirtualHost *:80&gt;\n        ServerName home.com\n\n        ProxyRequests on\n        AllowCONNECT 70\n        ProxyVia on\n        &lt;Proxy *&gt;\n                Order deny,allow\n                Allow from all\n        &lt;\/Proxy&gt;\n&lt;\/VirtualHost&gt;\n<\/pre>\n\nEnable the proxy connect module in Apache. On Ubuntu you just have to have the following symbolic links in <code lang=\"bash\" inline=\"on\">\/etc\/apache2\/mods-enabled<\/code>:\n\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nproxy.conf -&gt; ..\/mods-available\/proxy.conf\nproxy_connect.load -&gt; ..\/mods-available\/proxy_connect.load\nproxy_http.load -&gt; ..\/mods-available\/proxy_http.load\nproxy.load -&gt; ..\/mods-available\/proxy.load\n<\/pre>\n\nConfigure Stunnel on the server the same way as for <a href=\"http:\/\/ebixio.com\/blog\/2010\/02\/13\/tunneling-ssh-option-1\/\">option 1<\/a>.\n\nOn the client PC, this is the proxytunnel command line you'll need to use:\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nC:\\&gt;proxytunnel.exe -p proxy.work.com:1080 -d home.com:70 -r home.com:80 -a 71\n<\/pre>\n\nConfigure the work.com stunnel:\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsslVersion = SSLv3\n\n; Use it for client mode\nclient = yes\n\n&#x5B;apache-ssh]\naccept\t= 32\nconnect\t= 71\n<\/pre>\n\n<p>Restart apache and stunnel on the server side.<\/p>\n<p>On the client side:<\/p>\n<ol>\n<li>Start proxytunnel using the command shown above.<\/li>\n<li>Start stunnel. If the stunnel.conf file is in the default location, no command line arguments are needed. If not, pass the config line as a command line argument to stunnel.<\/li>\n<li>Start the ssh clinet and connect to 127.0.0.1:32<\/li>\n<\/ol>\n<p>Here&#8217;s what&#8217;s going on:<\/p>\n<ul>\n<li>The ssh client connects to port 32 on the localhost<\/li>\n<li>Stunnel is listening on port 32 on the localhost, so it receives that connection and sends it on to port 71 also on the localhost<\/li>\n<li>ProxyTunnel is listening on port 71, so it takes that connection from Stunnel and sends it to home.com:80 through proxy.work.com:8080<\/li>\n<li>The Apache server running at home.com:80 receives a CONNECT request for home.com:70, so it forwards the connection to that destination.<\/li>\n<li>Stunnel is listening on port 70 at home.com and when it receives the connection from Apache, it sends it to port 22 on home.com<\/li>\n<li>Finally, sshd is listening on home.com:22 so it receives the connection from Stunnel, allowing the user to log in<\/li>\n<\/ul>\n<p>This is even less efficient than the <a href=\"http:\/\/ebixio.com\/blog\/2010\/02\/13\/tunneling-ssh-option-1\/\">first option<\/a>, but has the advantage of not requiring another service to be exposed directly to the internet through the firewall.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>See the previous post for an explanation of what we\u2019re trying to accomplish. This is a diagram of what the setup looks like. The numbers shown are the TCP ports used by the various components. In the Apache config file: &lt;VirtualHost *:80&gt; ServerName home.com ProxyRequests on AllowCONNECT 70 ProxyVia on &lt;Proxy *&gt; Order deny,allow Allow [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[12,27,28],"class_list":["post-189","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-linux","tag-ssh","tag-tunnel"],"_links":{"self":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/posts\/189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/comments?post=189"}],"version-history":[{"count":0,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/posts\/189\/revisions"}],"wp:attachment":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/media?parent=189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/categories?post=189"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/tags?post=189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}