{"id":7591,"date":"2020-06-18T14:53:28","date_gmt":"2020-06-18T14:53:28","guid":{"rendered":"https:\/\/cloudkul.com\/blog\/?p=7591"},"modified":"2020-06-18T14:53:30","modified_gmt":"2020-06-18T14:53:30","slug":"how-to-use-ssh-to-connect-to-a-remote-server-in-linux","status":"publish","type":"post","link":"https:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/","title":{"rendered":"How To Use SSH To Connect To A Remote Server In Linux"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">What Is SSH?<\/h2>\n\n\n\n<p>Secure Shell, sometimes referred to as&nbsp;<strong>Secure Socket Shell<\/strong>, is a protocol that allows you to connect securely to a remote computer or a server by using a text-based interface.<\/p>\n\n\n\n<p>When a&nbsp;secure SSH connection&nbsp;is established, a shell session will be started, and you will be able to manipulate the server by typing commands within the client on your local computer.<\/p>\n\n\n\n<p>You can use SSH keys to identify trusted computers without the need for passwords and to interact with your servers.<\/p>\n\n\n\n<p>SSH is encrypted with Secure Sockets Layer (SSL), which makes it difficult for these communications to be intercepted and read.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Install an OpenSSH Client<\/h2>\n\n\n\n<p>Many Linux distributions already have an SSH client, run the following command to install the OpenSSH client on your Linux computer:<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<ol><li><code>sudo apt-get install openssh-client<\/code><\/li><li>Type in your superuser password when asked.<\/li><li>Hit Enter to complete the installation.<\/li><\/ol>\n\n\n\n<p><\/p>\n<\/div><\/div>\n\n\n\n<p>you can check if the SSH server is running on the machine by typing this command:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><code>sudo service ssh status<\/code><\/p><\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How To Create SSH Keys<\/h2>\n\n\n\n<p>SSH keys should be generated on the computer you wish to log in\u00a0from.<\/p>\n\n\n\n<p>Enter the following into the command line:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><code>ssh-keygen -t rsa <\/code><\/p><\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<p>Press enter multiple times to accept the defaults. Your keys will be generated at\u00a0<em>~\/.ssh\/id_rsa.pub<\/em>\u00a0and\u00a0<em>~\/.ssh\/id_rsa<\/em>.<\/p>\n\n\n\n<p>Switch into the\u00a0<code>.ssh<\/code>\u00a0directory using the command given below:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><code>cd ~\/.ssh <\/code><br><\/p><\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Look at the permissions of the files using the command given below:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><strong>ls -l<\/strong><\/p><\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<p>the\u00a0<code>id_rsa<\/code>\u00a0file should be readable and writable only to the owner to keep it secret.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Connect via SSH<\/h2>\n\n\n\n<ul><li>Command to access a remote server using terminal:<\/li><\/ul>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><code>ssh your_username@host_ip_address<\/code><\/p><\/blockquote>\n\n\n\n<p>And hit&nbsp;Enter.<\/p>\n\n\n\n<ul><li> Type in your password and hit\u00a0Enter.<\/li><li>When you are connecting to a server for the very first time, it will ask you if you want to continue connecting. Just type yes and hit\u00a0Enter.<\/li><li>An ECDSA key fingerprint is now added and you are connected to the remote server.<\/li><\/ul>\n\n\n\n<p><strong>NOTE:<\/strong> The default port is 22 if nobody changed the configuration in the sshd_config file. You may also just append the port number after the host IP address.<\/p>\n\n\n\n<p>Here is the example of a connection request using the OpenSSH client. We will specify the customized port number as well:<br><\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><strong>ssh your_username@host_ip_address -p 18765<\/strong><\/p><\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Connect With An SSH Client Using An SSH Key<\/h2>\n\n\n\n<p><br>Set the permissions for your private key file (<em>.pem<\/em>) to 400 using a command like the one below.<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<blockquote class=\"wp-block-quote\"><p><code><strong>chmod 400 mykey.pem<\/strong><\/code><\/p><\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<p>Command to access a remote server using a pem file:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><strong>ssh -i mykey.pem your_username@host_ip_address<\/strong><\/p><\/blockquote>\n<\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>You are now able to manage and control a remote machine using your terminal. If you have trouble connecting to a remote server, make sure that:<\/p>\n\n\n\n<ul><li>The IP address of the remote machine is correct.<\/li><li>The port SSH daemon is listening to is not blocked by a firewall or forwarded incorrectly.<\/li><li>Your username and password are correct.<\/li><li>The SSH services are installed properly.<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<br><\/h2>\n\n\n\n<p>As you will use the various options, you will find more advanced features that can make your life easier. SSH is most popular because it is secure, light-weight.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>For further any help or query, please\u00a0<a href=\"https:\/\/cloudkul.com\/contact\/\">contact<\/a>\u00a0us.<\/strong><br><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What Is SSH? Secure Shell, sometimes referred to as&nbsp;Secure Socket Shell, is a protocol that <a class=\"text-primary\" title=\"read more\" href=\"https:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[91,269,39],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How To Use SSH To Connect To A Remote Server In Linux - Cloudkul<\/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:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/\" \/>\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 To Connect To A Remote Server In Linux - Cloudkul\" \/>\n<meta property=\"og:description\" content=\"What Is SSH? Secure Shell, sometimes referred to as&nbsp;Secure Socket Shell, is a protocol that [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudkul\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-18T14:53:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-06-18T14:53:30+00:00\" \/>\n<meta name=\"author\" content=\"Nitin Kaushik\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/\",\"url\":\"https:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/\",\"name\":\"How To Use SSH To Connect To A Remote Server In Linux - Cloudkul\",\"isPartOf\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\"},\"datePublished\":\"2020-06-18T14:53:28+00:00\",\"dateModified\":\"2020-06-18T14:53:30+00:00\",\"author\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/99e46a85b2ad2848198f6de2c90bcbc4\"},\"breadcrumb\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Use SSH To Connect To A Remote Server In Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\",\"url\":\"https:\/\/cloudkul.com\/blog\/\",\"name\":\"Cloudkul\",\"description\":\"Host your eCommerce Store on AWS with Optimized Performance\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudkul.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/99e46a85b2ad2848198f6de2c90bcbc4\",\"name\":\"Nitin Kaushik\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fdc703824bce4bae43a834dfdf641f46?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/fdc703824bce4bae43a834dfdf641f46?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"caption\":\"Nitin Kaushik\"},\"url\":\"https:\/\/cloudkul.com\/blog\/author\/nitin-kaushik680\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Use SSH To Connect To A Remote Server In Linux - Cloudkul","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:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/","og_locale":"en_US","og_type":"article","og_title":"How To Use SSH To Connect To A Remote Server In Linux - Cloudkul","og_description":"What Is SSH? Secure Shell, sometimes referred to as&nbsp;Secure Socket Shell, is a protocol that [...]","og_url":"https:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/","og_site_name":"Cloudkul","article_published_time":"2020-06-18T14:53:28+00:00","article_modified_time":"2020-06-18T14:53:30+00:00","author":"Nitin Kaushik","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/","url":"https:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/","name":"How To Use SSH To Connect To A Remote Server In Linux - Cloudkul","isPartOf":{"@id":"https:\/\/cloudkul.com\/blog\/#website"},"datePublished":"2020-06-18T14:53:28+00:00","dateModified":"2020-06-18T14:53:30+00:00","author":{"@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/99e46a85b2ad2848198f6de2c90bcbc4"},"breadcrumb":{"@id":"https:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cloudkul.com\/blog\/how-to-use-ssh-to-connect-to-a-remote-server-in-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How To Use SSH To Connect To A Remote Server In Linux"}]},{"@type":"WebSite","@id":"https:\/\/cloudkul.com\/blog\/#website","url":"https:\/\/cloudkul.com\/blog\/","name":"Cloudkul","description":"Host your eCommerce Store on AWS with Optimized Performance","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudkul.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/99e46a85b2ad2848198f6de2c90bcbc4","name":"Nitin Kaushik","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/fdc703824bce4bae43a834dfdf641f46?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fdc703824bce4bae43a834dfdf641f46?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","caption":"Nitin Kaushik"},"url":"https:\/\/cloudkul.com\/blog\/author\/nitin-kaushik680\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/7591"}],"collection":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/comments?post=7591"}],"version-history":[{"count":56,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/7591\/revisions"}],"predecessor-version":[{"id":7647,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/7591\/revisions\/7647"}],"wp:attachment":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media?parent=7591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/categories?post=7591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/tags?post=7591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}