{"id":61681,"date":"2024-12-09T20:19:08","date_gmt":"2024-12-09T20:19:08","guid":{"rendered":"https:\/\/proxidize.com\/?post_type=blog&#038;p=61681"},"modified":"2026-01-13T17:26:12","modified_gmt":"2026-01-13T17:26:12","slug":"how-to-use-ssh-to-connect-to-a-linux-server","status":"publish","type":"blog","link":"https:\/\/proxidize.com\/blog\/how-to-use-ssh-to-connect-to-a-linux-server\/","title":{"rendered":"How to Use SSH to Connect to a Linux Server"},"content":{"rendered":"\n<p>Secure Shell, or SSH, is a protocol that lets you securely connect to a remote device like a Raspberry Pi or Ubuntu server over a network. By using SSH, you can access the device\u2019s terminal from your own computer. This is ideal for those who don\u2019t have physical access to a device or want to manage it remotely.<\/p>\n\n\n\n<p>This article is a step-by-step guide on how to connect to a Linux-based device. We\u2019ll discuss two scenarios. First, if your computer and your device are on the same network and second, if your device is on a different network than your computer.<\/p>\n\n\n\n<p>SSH allows you to remotely access your device, install software, run updates, troubleshoot issues, or restart it. You can do this from your computer\u2019s terminal or an SSH client like <a href=\"https:\/\/www.putty.org\/\" target=\"_blank\" rel=\"noopener\">PuTTY<\/a>.<\/p>\n\n\n\n<p>To start, you\u2019ll need three pieces of information.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Your device\u2019s local IP address<\/li>\n\n\n\n<li>Username for your device<\/li>\n\n\n\n<li>Password<\/li>\n<\/ol>\n\n\n\n<div style=\"height:12px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Many devices come with a default username and password which you can change once you\u2019re connected.<\/p>\n\n\n\n<div style=\"height:24px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Use SSH to Connect on the Same Network<\/h2>\n\n\n\n<p>If you\u2019re on the same network, you can find your device\u2019s local IP via your router\u2019s DHCP client list or by running the following command on the device itself.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.75rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * .75rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#232136;display:none;background-color:#e0def4\" aria-label=\"Copy\" data-copied-text=\"Copied!\" data-has-text-button=\"textSimple\" data-inside-header-type=\"none\" aria-live=\"polite\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>hostname -I<\/textarea><\/pre><span class=\"cbp-btn-text\">Copy<\/span><\/span><pre class=\"shiki rose-pine-moon\" style=\"background-color: #232136\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #EA9A97\">hostname<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #3E8FB0\">-I<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Once you know your device\u2019s local IP, username, and password, you can attempt an SSH connection by running this command in your terminal.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.75rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * .75rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#232136;display:none;background-color:#e0def4\" aria-label=\"Copy\" data-copied-text=\"Copied!\" data-has-text-button=\"textSimple\" data-inside-header-type=\"none\" aria-live=\"polite\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>ssh device_username@device_IP_address<\/textarea><\/pre><span class=\"cbp-btn-text\">Copy<\/span><\/span><pre class=\"shiki rose-pine-moon\" style=\"background-color: #232136\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #EA9A97\">ssh<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">device_username@device_IP_address<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>You\u2019ll then be prompted for the password. Once logged in you should consider changing the default login credentials.<\/p>\n\n\n\n<div style=\"height:24px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Use SSH to Connect on a Different Network<\/h2>\n\n\n\n<p>If you\u2019re not on the same network as your device, you\u2019ll have to take a few additional steps before you can connect to your <a href=\"https:\/\/proxidize.com\/proxy-server\/\">proxy server<\/a> remotely. This can be done by either port forwarding or using a VPN. We\u2019ll explain both methods now.<\/p>\n\n\n\n<div style=\"height:12px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Using a VPN to Connect Remotely<\/h4>\n\n\n\n<p>A VPN creates a secure encrypted tunnel between your remote computer and the local network your proxy server is on. This makes it appear as if your device and server are on the same local network without exposing SSH directly to the internet.<\/p>\n\n\n\n<p>Some routers support built-in VPN servers, however services like <a href=\"https:\/\/tailscale.com\/\" target=\"_blank\" rel=\"noopener\">Tailscale<\/a> offer convenient solutions for setting up virtual networks that let you securely access your device without complicated router configurations.<\/p>\n\n\n\n<p><strong>Note:<\/strong> This is the recommended method to remotely access your device! It is a much more secure option.<\/p>\n\n\n\n<p>After setting up the VPN and connecting, you can SSH using the proxy server\u2019s internal LAN IP as if it were physically on the same network.<\/p>\n\n\n\n<div style=\"height:12px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Port Forwarding on Your Router<\/h4>\n\n\n\n<p>Port forwarding will let external traffic access a specific device on a network. This needs to be done for the router your proxy server is connected to. I would strongly advise you to avoid resorting to port forwarding unless you <em>really<\/em> know what you\u2019re doing. This should be a last resort, as it opens your device up to the world and comes with considerable risk. To set up port forwarding you need to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Log into the router\u2019s admin panel and locate the \u201cPort Forwarding\u201d or \u201cVirtual Server\u201d section.<\/li>\n\n\n\n<li>Forward port 22 (the default SSH port) from the router\u2019s public IP to your device\u2019s internal IP and port 22.<br><br><strong>Note:<\/strong> Sometimes ISPs block certain ports, including port 22. If SSH isn\u2019t working on port 22, consider using a non-standard port (for example, 2222) for the external mapping. For instance, you can forward port 2222 on your router to port 22 on your device.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:12px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>After setting this up, you can connect using your router\u2019s public IP.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:12px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>To do so you can use the following command in the terminal:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.75rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * .75rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#232136;display:none;background-color:#e0def4\" aria-label=\"Copy\" data-copied-text=\"Copied!\" data-has-text-button=\"textSimple\" data-inside-header-type=\"none\" aria-live=\"polite\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>ssh username@&lt;YOUR_ROUTER_PUBLIC_IP><\/textarea><\/pre><span class=\"cbp-btn-text\">Copy<\/span><\/span><pre class=\"shiki rose-pine-moon\" style=\"background-color: #232136\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #EA9A97\">ssh<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">username@<\/span><span style=\"color: #3E8FB0\">&lt;<\/span><span style=\"color: #F6C177\">YOUR_ROUTER_PUBLIC_I<\/span><span style=\"color: #E0DEF4\">P<\/span><span style=\"color: #3E8FB0\">&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>If using a non-standard port:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.75rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * .75rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#232136;display:none;background-color:#e0def4\" aria-label=\"Copy\" data-copied-text=\"Copied!\" data-has-text-button=\"textSimple\" data-inside-header-type=\"none\" aria-live=\"polite\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>ssh -p 2222 username@&lt;YOUR_ROUTER_PUBLIC_IP><\/textarea><\/pre><span class=\"cbp-btn-text\">Copy<\/span><\/span><pre class=\"shiki rose-pine-moon\" style=\"background-color: #232136\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #EA9A97\">ssh<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #3E8FB0\">-p<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #EA9A97\">2222<\/span><span style=\"color: #E0DEF4\"> <\/span><span style=\"color: #F6C177\">username@<\/span><span style=\"color: #3E8FB0\">&lt;<\/span><span style=\"color: #F6C177\">YOUR_ROUTER_PUBLIC_I<\/span><span style=\"color: #E0DEF4\">P<\/span><span style=\"color: #3E8FB0\">&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Even after all of this, it\u2019s possible that your ISP uses <a href=\"https:\/\/proxidize.com\/blog\/what-is-ccgnat\/\" target=\"_blank\" rel=\"noreferrer noopener\">CGNAT<\/a> or another layer of <a href=\"https:\/\/proxidize.com\/blog\/what-is-nat\/\" target=\"_blank\" rel=\"noreferrer noopener\">NAT<\/a>, which means you won\u2019t have the real public IP address of your router. In this case, port forwarding alone won\u2019t be enough.<\/p>\n\n\n\n<p>If this is the case, you should reconsider using a VPN service instead of port forwarding. Alternatively you could contact your ISP to ask if they could provide a public IP address or enable a setting that grants you external access.<\/p>\n\n\n\n<p>There are some security considerations you should take into account to keep your network safe:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Change the default SSH credentials before opening the port.<\/strong> Choosing a secure password is a very important step to protect against automated attacks. Better yet, use <a href=\"https:\/\/www.ssh.com\/academy\/ssh\/public-key-authentication\" target=\"_blank\" rel=\"noopener\">public key authentication<\/a>, which is even more secure than a strong password. Public keys are much harder to brute force than passwords and are considered a best practice.<\/li>\n\n\n\n<li>Consider changing the default SSH port to something non-standard.<\/li>\n\n\n\n<li>Regularly update device software to patch vulnerabilities.<\/li>\n\n\n\n<li>Regularly check your device\u2019s SSH logs (<code>\/var\/log\/auth.log<\/code> on Ubuntu\/Raspberry Pi or equivalent paths on other systems) for unauthorized access attempts.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:24px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>To use SSH to connect to a Linux server can be a straightforward process requiring only a few commands. If your device is on the same network, it\u2019s as easy as finding its local IP and typing out a simple <code>ssh<\/code> command. Even if your device is on a different network, a VPN can make connecting to your device with SSH a very safe and secure process as well.<\/p>\n\n\n\n<p>While port forwarding is an option to facilitate SSH, it comes with a host of security concerns, as anything that requires you to open your computer up to the entire internet would.<\/p>\n\n\n\n<p>Remember that security is just as important as accessibility \u2014 never compromise the former for the latter. Changing your default credentials and using a strong password are the bare minimum. Using public key authentication, monitoring SSH logs, and regularly updating your software are all important ways to keep your server safe.<\/p>\n","protected":false},"author":2284,"featured_media":75715,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","categories":[266],"tags":[],"class_list":["post-61681","blog","type-blog","status-publish","format-standard","has-post-thumbnail","hentry","category-tech-tutorials-and-programming"],"acf":[],"_links":{"self":[{"href":"https:\/\/proxidize.com\/wp-json\/wp\/v2\/blog\/61681","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/proxidize.com\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/proxidize.com\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/proxidize.com\/wp-json\/wp\/v2\/users\/2284"}],"replies":[{"embeddable":true,"href":"https:\/\/proxidize.com\/wp-json\/wp\/v2\/comments?post=61681"}],"version-history":[{"count":7,"href":"https:\/\/proxidize.com\/wp-json\/wp\/v2\/blog\/61681\/revisions"}],"predecessor-version":[{"id":94433,"href":"https:\/\/proxidize.com\/wp-json\/wp\/v2\/blog\/61681\/revisions\/94433"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/proxidize.com\/wp-json\/wp\/v2\/media\/75715"}],"wp:attachment":[{"href":"https:\/\/proxidize.com\/wp-json\/wp\/v2\/media?parent=61681"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/proxidize.com\/wp-json\/wp\/v2\/categories?post=61681"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/proxidize.com\/wp-json\/wp\/v2\/tags?post=61681"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}