{"id":1357,"date":"2014-11-14T23:35:06","date_gmt":"2014-11-15T05:35:06","guid":{"rendered":"http:\/\/blog.supportpro.com\/?p=1357"},"modified":"2026-03-25T04:50:22","modified_gmt":"2026-03-25T10:50:22","slug":"ssh-tunneling","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/ssh-tunneling\/","title":{"rendered":"SSH tunneling"},"content":{"rendered":"\n<p><strong>SSH tunneling<\/strong> is used to tunnel all of the traffic from your local machine to a remote server that you have an account. SSH allows users to create TCP tunnels to send data over the network. The amazing thing about SSH tunnels is that they are encrypted.<\/p>\n\n\n\n<p><strong>How tunneling works?<\/strong><\/p>\n\n\n\n<p>This works by allocating a socket to listen to port on the local side, optionally bound to the specified bind_address. Whenever a connection is made to this port, the connection is forwarded over the secure channel, and a connection is made to host port from the remote machine. Port forwardings can also be specified in the configuration file.<\/p>\n\n\n\n<p>There are two ways to create an SSH tunnel: <strong>local and remote port forwarding<\/strong><wp-block data-block=\"core\/more\"><\/wp-block><\/p>\n\n\n\n<p>Local port forwarding is used in cases where we are on a private network which doesn\u2019t allow connections to a specific server.<br>For eg. lets say an a website test.com being blocked on a network. In this case we can create a tunnel through a server which isn\u2019t on our network and thus can access the website.<\/p>\n\n\n\n<p>For that use the following command in linux<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em># ssh user@work.example.org -L 10000:test.com:80<\/em><\/code><\/pre>\n\n\n\n<p>The key here is -L which says we\u2019re doing local port forwarding. Then it says we\u2019re forwarding our local port 10000 to test.com:80, which is the default port for HTTP. Now open your browser and go to http:\/\/localhost:10000.<br>Remote <a href=\"https:\/\/www.supportpro.com\/blog\/understanding-ssh-port-forwarding-your-complete-guide-explained\/\">port forwarding<\/a> is used to giving access to a service (SSH port tcp\/22) on your home machine (localhost) to people at work. Use the following syntax for it :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><em># ssh user@work.example.org -R 10000:localhost:22<\/em><\/code><\/pre>\n\n\n\n<p>First you need to specify a local port on your machine which you wish to expose publicly, which in this case is 10000.<br>Next there is the address on which the server should listen to, and a port on which the server should listen to, which in this case is 22.<br>There is one more thing you need to do to enable this. SSH doesn\u2019t by default allow remote hosts to forwarded ports.<br>To enable this open \/etc\/ssh\/sshd_config using any file editor and add the following line somewhere in that config file.<\/p>\n\n\n\n<p>===<br>GatewayPorts yes<br>===<\/p>\n\n\n\n<p>After it save the file and restart the SSH service.<\/p>\n\n\n\n<p><span style=\"text-decoration: underline;\"><strong>Steps for tunneling in windows using putty<\/strong><\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Launch putty and head to Connection > SSH > Tunnels<\/li>\n\n\n\n<li>In the Source port field, enter a port number that your computer will listen for traffic on. Be sure to pick one that isn&#8217;t being used by another program. (9000 should be a safe bet) .<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><a class=\"lightbox\" href=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2014\/11\/Steps-for-tunneling-in-windows-using-putty.png\" data-rel=\"penci-gallery-image-content\" ><img fetchpriority=\"high\" decoding=\"async\" width=\"300\" height=\"197\" src=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2014\/11\/Steps-for-tunneling-in-windows-using-putty-300x197.png\" alt=\"\" class=\"wp-image-4821\" srcset=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2014\/11\/Steps-for-tunneling-in-windows-using-putty-300x197.png 300w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2014\/11\/Steps-for-tunneling-in-windows-using-putty.png 670w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Then select Dynamic and Auto as the port type and then click Add. Then scroll back up and click on Session.<\/li>\n\n\n\n<li>Enter the IP address of the machine running the SSH server in the Host Name (or IP address<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><a class=\"lightbox\" href=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2014\/11\/Steps-for-tunneling-in-windows-using-putty2.png\" data-rel=\"penci-gallery-image-content\" ><img decoding=\"async\" width=\"300\" height=\"197\" src=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2014\/11\/Steps-for-tunneling-in-windows-using-putty2-300x197.png\" alt=\"\" class=\"wp-image-4820\" srcset=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2014\/11\/Steps-for-tunneling-in-windows-using-putty2-300x197.png 300w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2014\/11\/Steps-for-tunneling-in-windows-using-putty2.png 670w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Then type a name in the Saved Sessions box and click Save for future usage.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Now you can double click on the name of the saved session to start up the tunnel.<\/li>\n\n\n\n<li>You will have to enter your username and password before the tunnel will work correctly, unless the server is configured for anonymous logins.<\/li>\n<\/ul>\n\n\n\n<p>Once the SSH session is open and the tunnel is up. Learn&nbsp; more about <a href=\"https:\/\/www.supportpro.com\/blog\/ssh-securing-and-keygen\/\">SSH hardening and key generation tips<\/a><br>If you require help, <a href=\"https:\/\/www.supportpro.com\/requestquote.php\">contact SupportPRO Server Admin<\/a><\/p>\n\n\n\n<p class=\"has-text-align-center\"><span id=\"hs-cta-wrapper-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-wrapper\"><span id=\"hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-node hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\"><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/9d590242-d641-4383-94b4-8cfd62f0af6b\"><\/a><\/span><\/span><\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile is-vertically-aligned-center has-white-background-color has-background\"><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\">Partner with <strong>SupportPRO<\/strong> for 24\/7 proactive cloud support that keeps your business secure, scalable, and ahead of the curve.<\/p>\n\n\n\n<!--HubSpot Call-to-Action Code --><span class=\"hs-cta-wrapper\" id=\"hs-cta-wrapper-3350a795-db50-482f-9911-301930d1b1be\"><span class=\"hs-cta-node hs-cta-3350a795-db50-482f-9911-301930d1b1be\" id=\"hs-cta-3350a795-db50-482f-9911-301930d1b1be\"><!--[if lte IE 8]><div id=\"hs-cta-ie-element\"><\/div><![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/3350a795-db50-482f-9911-301930d1b1be\" ><img decoding=\"async\" class=\"hs-cta-img\" id=\"hs-cta-img-3350a795-db50-482f-9911-301930d1b1be\" style=\"border-width:0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/3350a795-db50-482f-9911-301930d1b1be.png\"  alt=\"Contact Us today!\"\/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '3350a795-db50-482f-9911-301930d1b1be', {\"useNewLoader\":\"true\",\"region\":\"na1\"}); <\/script><\/span><!-- end HubSpot Call-to-Action Code -->\n<\/div><figure class=\"wp-block-media-text__media\"><img decoding=\"async\" width=\"904\" height=\"931\" src=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png\" alt=\"guy server checkup\" class=\"wp-image-12943 size-full\" srcset=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png 904w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-291x300.png 291w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-768x791.png 768w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-585x602.png 585w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>SSH tunneling is used to tunnel all of the traffic from your local machine to a remote server that you have an account. SSH allows users to create TCP tunnels&hellip;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[1,3],"tags":[],"class_list":["post-1357","post","type-post","status-publish","format-standard","hentry","category-miscellaneous","category-technical-articles"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/1357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=1357"}],"version-history":[{"count":8,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/1357\/revisions"}],"predecessor-version":[{"id":16596,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/1357\/revisions\/16596"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=1357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=1357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=1357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}