{"id":16362,"date":"2024-10-31T19:34:41","date_gmt":"2024-10-31T19:34:41","guid":{"rendered":"https:\/\/truehost.com\/support\/?post_type=docs&#038;p=16362"},"modified":"2024-11-02T07:04:35","modified_gmt":"2024-11-02T07:04:35","password":"","slug":"how-to-use-ssh-tunneling-for-secure-remote-access","status":"publish","type":"docs","link":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-use-ssh-tunneling-for-secure-remote-access\/","title":{"rendered":"How to Use SSH Tunneling for Secure Remote Access"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">What is SSH Tunneling?<\/h3>\n\n\n\n<p>SSH tunneling, or SSH port forwarding, allows you to securely route network traffic from your local machine through an SSH connection to a remote server. This is commonly used to access remote services that may not be directly accessible from your local network, adding an extra layer of security by encrypting the data in transit.<\/p>\n\n\n\n<p>There are three main types of SSH tunneling:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Local Port Forwarding<\/strong>: Redirects traffic from your local computer to a remote service through the SSH server.<\/li>\n\n\n\n<li><strong>Remote Port Forwarding<\/strong>: Allows applications on the remote server to access a local service on your computer.<\/li>\n\n\n\n<li><strong>Dynamic Port Forwarding<\/strong>: Configures a local SOCKS proxy, enabling access to multiple networked services through a single SSH tunnel.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>SSH Access to the Remote Server<\/strong>: Ensure you have SSH access and permissions on the remote server.<\/li>\n\n\n\n<li><strong>OpenSSH Client<\/strong>: The <code>ssh<\/code> command-line tool (default on Linux and macOS, installable on Windows via WSL or with tools like PuTTY).<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">1. Setting Up Local Port Forwarding<\/h3>\n\n\n\n<p>Local port forwarding is useful for accessing a remote server\u2019s resources locally. For example, you can connect to a remote database or web service securely via SSH without directly exposing the remote server\u2019s ports.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Example: Accessing a Remote Web Server Locally<\/h4>\n\n\n\n<p>Suppose you want to securely access a web application on port <code>80<\/code> of a remote server from your local machine on port <code>8080<\/code>.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Run the following command on your local machine:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh -L 8080:localhost:80 user@remote-server<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>-L<\/strong> specifies local port forwarding.<\/li>\n\n\n\n<li><strong>8080<\/strong> is the local port on your computer.<\/li>\n\n\n\n<li><strong>localhost:80<\/strong> is the remote address and port of the service on the server.<\/li>\n\n\n\n<li><strong>user@remote-server<\/strong> is your SSH username and remote server IP or hostname.<\/li>\n<\/ul>\n\n\n\n<p>  2. Once connected, open <code>http:\/\/localhost:8080<\/code> in your browser to access the remote service securely.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Setting Up Remote Port Forwarding<\/h3>\n\n\n\n<p>Remote port forwarding allows the remote server to access a service on your local machine. This is useful for situations where you want to make a local application or service accessible to the remote server or its network.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Example: Making a Local Web Application Accessible to the Remote Server<\/h4>\n\n\n\n<p>Let\u2019s say you have a web server running locally on port <code>3000<\/code>, and you want it to be accessible from the remote server.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Run this command:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh -R 4000:localhost:3000 user@remote-server<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>-R<\/strong> specifies remote port forwarding.<\/li>\n\n\n\n<li><strong>4000<\/strong> is the port on the remote server.<\/li>\n\n\n\n<li><strong>localhost:3000<\/strong> is the local address and port on your machine.<\/li>\n\n\n\n<li><strong>user@remote-server<\/strong> is your SSH username and the remote server\u2019s address.<\/li>\n<\/ul>\n\n\n\n<p> 2. Now, on the remote server, accessing <code>localhost:4000<\/code> will connect to your local web server running on port <code>3000<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Setting Up Dynamic Port Forwarding<\/h3>\n\n\n\n<p>Dynamic port forwarding creates a SOCKS proxy on your local machine, allowing you to access multiple services on the remote network. This is particularly useful for secure browsing through an SSH server.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Example: Using SSH as a SOCKS Proxy<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open an SSH connection with dynamic port forwarding:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh -D 8080 -q -C -N user@remote-server<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>-D 8080<\/strong> specifies that the SOCKS proxy should run on port <code>8080<\/code>.<\/li>\n\n\n\n<li><strong>-q<\/strong> suppresses warnings and messages.<\/li>\n\n\n\n<li><strong>-C<\/strong> enables data compression.<\/li>\n\n\n\n<li><strong>-N<\/strong> tells SSH not to execute remote commands (useful for port forwarding only)<\/li>\n<\/ul>\n\n\n\n<p>2. Configure your browser or application to use <code>localhost:8080<\/code> as a SOCKS proxy.<\/p>\n\n\n\n<p>3. Now, all network requests from the browser will be tunneled securely through the SSH server.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Tips for SSH Tunneling<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Automate SSH Tunnel Creation<\/strong>: Use SSH config files to simplify tunnel commands. Edit <code>~\/.ssh\/config<\/code> and add entries like:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>Host my-tunnel\n    HostName remote-server\n    User user\n    LocalForward 8080 localhost:80<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Use Public Key Authentication<\/strong>: Instead of entering a password each time, set up SSH keys for secure, passwordless authentication.<\/li>\n\n\n\n<li><strong>Close Idle Tunnels<\/strong>: SSH tunnels consume resources. Close tunnels when not in use to maintain server performance and security.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Security Considerations<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Firewall Rules<\/strong>: Ensure firewalls allow the necessary SSH traffic but restrict access as needed to maintain security.<\/li>\n\n\n\n<li><strong>Restrict Remote Access<\/strong>: Only enable remote access (e.g., remote port forwarding) if necessary, as it can expose your local services.<\/li>\n\n\n\n<li><strong>Use Strong Authentication<\/strong>: Ensure SSH key-based authentication is enabled, and disable password authentication on the SSH server for better security.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Final Word<\/h3>\n\n\n\n<p>SSH tunneling is a versatile and secure way to access remote services. By using SSH\u2019s local, remote, or dynamic port forwarding, you can securely connect to otherwise restricted resources, enhancing both privacy and security for remote access needs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is SSH Tunneling? SSH tunneling, or SSH port forwarding, allows you to securely route network traffic from your local machine through an SSH connection to a remote server. This is commonly used to access remote services that may not be directly accessible from your local network, adding an extra layer of security by encrypting [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_eb_attr":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"doc_category":[1820,1824,1879,2128],"doc_tag":[],"class_list":["post-16362","docs","type-docs","status-publish","hentry","doc_category-cloud-servers-in-kenya","doc_category-dedicated-servers","doc_category-servers","doc_category-vps-servers"],"year_month":"2026-07","word_count":716,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"Eugene","author_nicename":"eugene","author_url":"https:\/\/truehost.com\/support\/author\/eugene\/"},"doc_category_info":[{"term_name":"Cloud servers in Kenya","term_url":"https:\/\/truehost.com\/support\/docs-category\/cloud-servers-in-kenya\/"},{"term_name":"dedicated servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/dedicated-servers\/"},{"term_name":"Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/servers\/"},{"term_name":"VPS-Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/vps-servers\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Use SSH Tunneling for Secure Remote Access -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-use-ssh-tunneling-for-secure-remote-access\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Use SSH Tunneling for Secure Remote Access -\" \/>\n<meta property=\"og:description\" content=\"What is SSH Tunneling? SSH tunneling, or SSH port forwarding, allows you to securely route network traffic from your local machine through an SSH connection to a remote server. This is commonly used to access remote services that may not be directly accessible from your local network, adding an extra layer of security by encrypting [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-use-ssh-tunneling-for-secure-remote-access\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-02T07:04:35+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-use-ssh-tunneling-for-secure-remote-access\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-use-ssh-tunneling-for-secure-remote-access\\\/\",\"name\":\"How to Use SSH Tunneling for Secure Remote Access -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\"},\"datePublished\":\"2024-10-31T19:34:41+00:00\",\"dateModified\":\"2024-11-02T07:04:35+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-use-ssh-tunneling-for-secure-remote-access\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-use-ssh-tunneling-for-secure-remote-access\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-use-ssh-tunneling-for-secure-remote-access\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/truehost.com\\\/support\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Use SSH Tunneling for Secure Remote Access\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"name\":\"\",\"description\":\"Help In a Click\",\"publisher\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/truehost.com\\\/support\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\",\"name\":\"Truehost Kenya\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"width\":240,\"height\":48,\"caption\":\"Truehost Kenya\"},\"image\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Use SSH Tunneling for Secure Remote Access -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-use-ssh-tunneling-for-secure-remote-access\/","og_locale":"en_US","og_type":"article","og_title":"How to Use SSH Tunneling for Secure Remote Access -","og_description":"What is SSH Tunneling? SSH tunneling, or SSH port forwarding, allows you to securely route network traffic from your local machine through an SSH connection to a remote server. This is commonly used to access remote services that may not be directly accessible from your local network, adding an extra layer of security by encrypting [&hellip;]","og_url":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-use-ssh-tunneling-for-secure-remote-access\/","article_modified_time":"2024-11-02T07:04:35+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-use-ssh-tunneling-for-secure-remote-access\/","url":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-use-ssh-tunneling-for-secure-remote-access\/","name":"How to Use SSH Tunneling for Secure Remote Access -","isPartOf":{"@id":"https:\/\/truehost.com\/support\/#website"},"datePublished":"2024-10-31T19:34:41+00:00","dateModified":"2024-11-02T07:04:35+00:00","breadcrumb":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-use-ssh-tunneling-for-secure-remote-access\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/truehost.com\/support\/knowledge-base\/how-to-use-ssh-tunneling-for-secure-remote-access\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-use-ssh-tunneling-for-secure-remote-access\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/truehost.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to Use SSH Tunneling for Secure Remote Access"}]},{"@type":"WebSite","@id":"https:\/\/truehost.com\/support\/#website","url":"https:\/\/truehost.com\/support\/","name":"","description":"Help In a Click","publisher":{"@id":"https:\/\/truehost.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/truehost.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/truehost.com\/support\/#organization","name":"Truehost Kenya","url":"https:\/\/truehost.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","width":240,"height":48,"caption":"Truehost Kenya"},"image":{"@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16362","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/comments?post=16362"}],"version-history":[{"count":2,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16362\/revisions"}],"predecessor-version":[{"id":16560,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16362\/revisions\/16560"}],"wp:attachment":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/media?parent=16362"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_category?post=16362"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_tag?post=16362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}