{"id":30332,"date":"2026-11-22T22:09:29","date_gmt":"2026-11-22T22:09:29","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=30332"},"modified":"2026-11-22T22:09:29","modified_gmt":"2026-11-22T22:09:29","slug":"how-to-login-linux-server-using-ssh","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-login-linux-server-using-ssh\/","title":{"rendered":"How to login linux server using ssh?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">You log in to a Linux server over SSH by running <code>ssh username@server-ip<\/code> from an SSH client, then proving who you are with either a password or a private key. This guide covers both methods on Windows, macOS and Linux, plus how to set up key-based login, fix the most common connection errors and lock down the server once you can reach it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1 &#8211; We need to use ssh client to be installed in a laptop.<\/h2>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">- putty\n- gitbash\n- SuperPuTTY\n- MobaXterm\n- mRemoteNG\n- https:<span class=\"hljs-comment\">\/\/www.devopsschool.com\/blog\/list-of-free-tools-for-tabbed-multiple-linux-ssh-putty-sessions\/<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Step 2 &#8211; SSH login method<\/h2>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">- Username &amp; password OR\n- Username &amp; pvt key (pem for ssh or ppk for putty)<\/code><\/span><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Step 3 &#8211; SSH login using server IP &amp; Username &amp; password<\/h2>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">putty:\n- server ip - 192.168.1.16\n- username - root\n- password - rajesh123\n\ngitbash &amp; Mac:\n- server ip\n- username\n- password\n$ ssh root@192.168.1.16<\/code><\/span><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Step 4 &#8211; SSH login using server IP &amp; Username &amp; pvt key<\/h2>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">putty using ppk file:\nfollow step <span class=\"hljs-number\">5<\/span> &amp; step <span class=\"hljs-number\">6<\/span> <span class=\"hljs-keyword\">from<\/span> - https:<span class=\"hljs-comment\">\/\/www.devopsschool.com\/blog\/how-to-login-linux-server-of-aws-from-windows-using-putty\/<\/span>\n\ngitbash using pem file &amp; Mac:\n$ ssh -i key.pem root@<span class=\"hljs-number\">192.168<\/span><span class=\"hljs-number\">.1<\/span><span class=\"hljs-number\">.16<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\"  id=\"_ytid_10470\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/ApDdY0K_Z7Q?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  epyt-is-override  no-lazyload\" title=\"YouTube player\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Reference<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/how-to-configure-and-access-linux-vms-using-virtualbox-for-local-lab-and-practice\/\">https:\/\/www.devopsschool.com\/blog\/how-to-configure-and-access-linux-vms-using-virtualbox-for-local-lab-and-practice\/<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/how-to-login-linux-server-of-aws-from-windows-using-putty\/\">https:\/\/www.devopsschool.com\/blog\/how-to-login-linux-server-of-aws-from-windows-using-putty\/<\/a><\/li>\n\n\n\n<li>Download gitbash for windows &#8211; <a href=\"https:\/\/git-scm.com\/downloads\" rel=\"noopener\">https:\/\/git-scm.com\/downloads<\/a><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">How an SSH login works<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">SSH (Secure Shell) has two parts. The <strong>client<\/strong> runs on your laptop: <code>ssh<\/code>, PuTTY, MobaXterm and so on. The <strong>server<\/strong> is the <code>sshd<\/code> daemon on the Linux machine, which listens on TCP port 22 by default. The client opens an encrypted connection, checks the server&#039;s host key, and then logs you in with one of the authentication methods the server allows.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Method<\/th><th>What you need<\/th><th>Typical use<\/th><\/tr><\/thead><tbody><tr><td>Password<\/td><td>Username and that user&#039;s password<\/td><td>Local lab VMs, first-time setup<\/td><\/tr><tr><td>Public key<\/td><td>Username and a private key file (OpenSSH format such as <code>.pem<\/code>, or <code>.ppk<\/code> for PuTTY)<\/td><td>Cloud servers (AWS, Azure, GCP) and production<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Windows 10, Windows 11 and current Windows Server releases come with the OpenSSH client, so the <code>ssh<\/code> commands in this guide work in PowerShell or Command Prompt as well as in Git Bash, macOS Terminal and Linux shells.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Check the server side before you connect<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Most failed logins happen because the server isn&#039;t reachable or <code>sshd<\/code> isn&#039;t running. If you have console access to the server (for example the VirtualBox window or a cloud serial console), check these first.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Find the server's IP address<\/span>\nip <span class=\"hljs-number\">-4<\/span> addr show\n\n<span class=\"hljs-comment\"># Check that the SSH daemon is running<\/span>\n<span class=\"hljs-comment\"># (the service is called 'sshd' on RHEL\/CentOS\/Fedora\/Amazon Linux, 'ssh' on Debian\/Ubuntu)<\/span>\nsudo systemctl status sshd    <span class=\"hljs-comment\"># or: sudo systemctl status ssh<\/span>\n\n<span class=\"hljs-comment\"># Confirm something is listening on port 22<\/span>\nsudo ss -tlnp | grep <span class=\"hljs-string\">':22'<\/span>\n\n<span class=\"hljs-comment\"># Install and start the server if it is missing<\/span>\nsudo apt install -y openssh-server &amp;&amp; sudo systemctl enable --now ssh      <span class=\"hljs-comment\"># Debian\/Ubuntu<\/span>\nsudo dnf install -y openssh-server &amp;&amp; sudo systemctl enable --now sshd     <span class=\"hljs-comment\"># RHEL family<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">On cloud servers you also need a security group or firewall rule that allows inbound TCP 22 from your public IP. Inside the server, <code>firewalld<\/code> or <code>ufw<\/code> can block the port too. Open it with <code>sudo firewall-cmd --permanent --add-service=ssh &amp;&amp; sudo firewall-cmd --reload<\/code> or <code>sudo ufw allow OpenSSH<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Log in with a username and password<\/h2>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">ssh devops@<span class=\"hljs-number\">192.168<\/span><span class=\"hljs-number\">.1<\/span><span class=\"hljs-number\">.16<\/span>\n\n<span class=\"hljs-comment\"># If the server listens on a non-default port<\/span>\nssh -p <span class=\"hljs-number\">2222<\/span> devops@<span class=\"hljs-number\">192.168<\/span><span class=\"hljs-number\">.1<\/span><span class=\"hljs-number\">.16<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">The first time you connect to a server, the client asks you to confirm its host key:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">The authenticity of host <span class=\"hljs-string\">'192.168.1.16 (192.168.1.16)'<\/span> can<span class=\"hljs-string\">'t be established.\nED25519 key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.\nAre you sure you want to continue connecting (yes\/no\/&#91;fingerprint])? yes\nWarning: Permanently added '<\/span><span class=\"hljs-number\">192.168<\/span><span class=\"hljs-number\">.1<\/span><span class=\"hljs-number\">.16<\/span><span class=\"hljs-string\">' (ED25519) to the list of known hosts.\ndevops@192.168.1.16'<\/span>s password:<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Type <code>yes<\/code> and the fingerprint is saved to <code>~\/.ssh\/known_hosts<\/code>. Then enter the password. Nothing appears on screen while you type it, and that&#039;s normal. When you see a prompt such as <code>[devops@server ~]$<\/code>, you&#039;re logged in. Type <code>exit<\/code> or press Ctrl+D to disconnect.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> On production systems, compare the fingerprint with the real one (run <code>ssh-keygen -lf \/etc\/ssh\/ssh_host_ed25519_key.pub<\/code> on the server console) before you type <code>yes<\/code>. Confirming the host key is what protects you from a man-in-the-middle attack.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Log in with a private key<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">OpenSSH won&#039;t use a private key file that other users can read. Lock down its permissions first, then pass the key with <code>-i<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># macOS, Linux, Git Bash<\/span>\nchmod <span class=\"hljs-number\">400<\/span> ~\/Downloads\/key.pem\nssh -i ~\/Downloads\/key.pem ec2-user@<span class=\"hljs-number\">203.0<\/span><span class=\"hljs-number\">.113<\/span><span class=\"hljs-number\">.10<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Windows PowerShell (built-in OpenSSH): remove inherited permissions and grant read only to yourself<\/span>\nicacls .\\key.pem \/inheritance:r\nicacls .\\key.pem \/grant:r <span class=\"hljs-string\">\"$($env:USERNAME):(R)\"<\/span>\nssh -i .\\key.pem ec2-user@<span class=\"hljs-number\">203.0<\/span><span class=\"hljs-number\">.113<\/span><span class=\"hljs-number\">.10<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Cloud images usually turn off direct root login and create a default user instead, so use the right username for the image:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Image<\/th><th>Default username<\/th><\/tr><\/thead><tbody><tr><td>Amazon Linux, RHEL on AWS<\/td><td><code>ec2-user<\/code><\/td><\/tr><tr><td>Ubuntu<\/td><td><code>ubuntu<\/code><\/td><\/tr><tr><td>Debian<\/td><td><code>admin<\/code><\/td><\/tr><tr><td>CentOS Stream \/ Rocky \/ AlmaLinux (varies by publisher)<\/td><td><code>centos<\/code>, <code>rocky<\/code>, <code>ec2-user<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">PuTTY needs the key in <code>.ppk<\/code> format. The <a href=\"https:\/\/www.devopsschool.com\/blog\/how-to-login-to-linux-server-using-putty\/\">PuTTY login guide<\/a> shows how to convert it with PuTTYgen. You can also convert in the other direction, from <code>.ppk<\/code> to OpenSSH format, so the same key works with the <code>ssh<\/code> command: <code>puttygen key.ppk -O private-openssh -o key.pem<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create your own key pair and save connection details<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you can already log in with a password, switch to key-based login. It&#039;s more secure and you won&#039;t need to type the password each time.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>On your laptop, generate a key pair: <code>ssh-keygen -t ed25519 -C &quot;you@laptop&quot;<\/code>. Accept the default path (<code>~\/.ssh\/id_ed25519<\/code>) and set a passphrase.<\/li>\n\n\n<li>Copy the public key to the server: <code>ssh-copy-id devops@192.168.1.16<\/code>. On Windows, where <code>ssh-copy-id<\/code> isn&#039;t available, run: <code>type $env:USERPROFILE\\.ssh\\id_ed25519.pub | ssh devops@192.168.1.16 &quot;mkdir -p ~\/.ssh &amp;&amp; chmod 700 ~\/.ssh &amp;&amp; cat &gt;&gt; ~\/.ssh\/authorized_keys &amp;&amp; chmod 600 ~\/.ssh\/authorized_keys&quot;<\/code>.<\/li>\n\n\n<li>Test it: <code>ssh devops@192.168.1.16<\/code>. You should be asked for the key passphrase (if you set one), not the account password.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Save frequently used servers in <code>~\/.ssh\/config<\/code> (on Windows, <code>C:\\Users\\&lt;you&gt;\\.ssh\\config<\/code>). After that, <code>ssh lab<\/code> is all you need to type:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">Host lab\n    HostName <span class=\"hljs-number\">192.168<\/span><span class=\"hljs-number\">.1<\/span><span class=\"hljs-number\">.16<\/span>\n    User devops\n    Port <span class=\"hljs-number\">22<\/span>\n    IdentityFile ~<span class=\"hljs-regexp\">\/.ssh\/i<\/span>d_ed25519\n    IdentitiesOnly yes<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Corrections to the steps above<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Built-in client on Windows:<\/strong> Git Bash still works, but it isn&#039;t required. Windows 10 and 11 ship with the OpenSSH <code>ssh<\/code> command.<\/li>\n\n\n<li><strong>Key permissions:<\/strong> <code>ssh -i key.pem<\/code> fails with <code>UNPROTECTED PRIVATE KEY FILE<\/code> unless you first run <code>chmod 400 key.pem<\/code> (or the <code>icacls<\/code> commands on Windows).<\/li>\n\n\n<li><strong>Root user:<\/strong> many distributions and almost all cloud images block root login over SSH. Log in as a normal user such as <code>ec2-user<\/code> or <code>ubuntu<\/code>, then use <code>sudo<\/code>.<\/li>\n\n\n<li><strong>Passwords in examples:<\/strong> the example above shows a real-looking root password. Never share or reuse credentials like this. Use a strong unique password, or better, key-based login.<\/li>\n\n\n<li><strong>Missing details:<\/strong> use <code>-p PORT<\/code> when the server doesn&#039;t listen on port 22, and expect the host key confirmation prompt the first time you connect.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Common SSH errors and fixes<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Error<\/th><th>Likely cause<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td><code>Connection timed out<\/code><\/td><td>Wrong IP, server down, or a firewall\/security group blocking port 22<\/td><td>Check the IP, the cloud inbound rules and <code>firewalld<\/code>\/<code>ufw<\/code><\/td><\/tr><tr><td><code>Connection refused<\/code><\/td><td><code>sshd<\/code> not running or listening on another port<\/td><td><code>sudo systemctl start sshd<\/code>; check <code>Port<\/code> in <code>\/etc\/ssh\/sshd_config<\/code><\/td><\/tr><tr><td><code>Permission denied (publickey)<\/code><\/td><td>Wrong username, wrong key, or password login disabled<\/td><td>Use the image&#039;s default user and the correct <code>-i<\/code> key; run <code>ssh -v<\/code> to see which keys are tried<\/td><\/tr><tr><td><code>WARNING: UNPROTECTED PRIVATE KEY FILE!<\/code><\/td><td>Key file can be read by other users<\/td><td><code>chmod 400 key.pem<\/code> or fix the ACL with <code>icacls<\/code><\/td><\/tr><tr><td><code>Load key &quot;key.ppk&quot;: invalid format<\/code><\/td><td>Passing a PuTTY key to OpenSSH<\/td><td>Convert with <code>puttygen key.ppk -O private-openssh -o key.pem<\/code><\/td><\/tr><tr><td><code>REMOTE HOST IDENTIFICATION HAS CHANGED!<\/code><\/td><td>Server was rebuilt or the IP was reused (or a real attack)<\/td><td>Verify the new fingerprint, then <code>ssh-keygen -R 192.168.1.16<\/code><\/td><\/tr><tr><td><code>Too many authentication failures<\/code><\/td><td>SSH agent offers too many keys before the right one<\/td><td>Add <code>-o IdentitiesOnly=yes<\/code> along with <code>-i<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> <code>ssh -v user@host<\/code> (or <code>-vvv<\/code> for more detail) prints each stage of the connection and authentication. It&#039;s the fastest way to see where a login fails.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Harden SSH once you can log in<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once key login works for a user with sudo rights, turn off root and password logins in <code>\/etc\/ssh\/sshd_config<\/code>. Also check for drop-in files under <code>\/etc\/ssh\/sshd_config.d\/<\/code>. <code>sshd<\/code> uses the first value it reads for each setting, so a drop-in (for example one created by cloud-init) can override your change.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">PermitRootLogin no\nPasswordAuthentication no\nPubkeyAuthentication yes<\/code><\/span><\/pre>\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Validate the configuration, then reload (service is 'ssh' on Debian\/Ubuntu)<\/span>\nsudo sshd -t &amp;&amp; sudo systemctl reload sshd<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Keep your current session open and test a new login in a second terminal before you close it. If the new config locks you out, you can still fix it from the open session.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">What is the basic command to SSH into a Linux server?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run <code>ssh username@server-ip<\/code>, for example <code>ssh devops@192.168.1.16<\/code>. Add <code>-i keyfile<\/code> to log in with a private key and <code>-p port<\/code> if the server doesn&#039;t use port 22.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Do I need PuTTY or Git Bash to use SSH on Windows?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. Windows 10 and 11 include the OpenSSH client, so <code>ssh<\/code> works directly in PowerShell or Command Prompt. PuTTY and MobaXterm are optional graphical alternatives.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why do I get Permission denied (publickey) on an AWS server?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The usual causes are the wrong username (use <code>ec2-user<\/code> for Amazon Linux or <code>ubuntu<\/code> for Ubuntu, not root) or the wrong key file. Run <code>ssh -v<\/code> to see which key is being offered.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is the difference between a .pem and a .ppk key?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Both can hold the same private key. <code>.pem<\/code> is the OpenSSH-compatible format used by the <code>ssh<\/code> command, and <code>.ppk<\/code> is PuTTY&#039;s own format. PuTTYgen converts between them.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I fix &#039;UNPROTECTED PRIVATE KEY FILE&#039;?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Make the key readable only by you. Run <code>chmod 400 key.pem<\/code> on macOS, Linux or Git Bash, or remove inherited permissions with <code>icacls<\/code> on Windows, then connect again.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related tutorials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/how-to-login-to-linux-server-using-putty\/\">How to Login to Linux Server using Putty?<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/operating-systems\/linux\/\">More Linux tutorials<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/pomerium-tutorial-complete-end-to-end-guide-to-zero-trust-access-identity-aware-proxy-sso-kubernetes-ssh-and-production-deployment\/\">Pomerium Tutorial: Complete End-to-End Guide to Zero-Trust Access, Identity-Aware Proxy, SSO, Kubernetes, SSH and Production Deployment<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>You log in to a Linux server over SSH by running ssh username@server-ip from an SSH client, then proving who you are with either a password or&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[4957],"tags":[896],"class_list":["post-30332","post","type-post","status-publish","format-standard","hentry","category-linux","tag-ssh"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=30332"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30332\/revisions"}],"predecessor-version":[{"id":80123,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30332\/revisions\/80123"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=30332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=30332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=30332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}