{"id":799,"date":"2016-02-18T06:36:43","date_gmt":"2016-02-18T06:36:43","guid":{"rendered":"http:\/\/cloudkul.com\/blog\/?p=799"},"modified":"2017-06-14T11:34:10","modified_gmt":"2017-06-14T11:34:10","slug":"securely-connecting-to-server-without-password-authentication-ssh-sftp","status":"publish","type":"post","link":"https:\/\/cloudkul.com\/blog\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/","title":{"rendered":"Securely Connecting To Server Without Password Authentication : SSH &amp; SFTP"},"content":{"rendered":"<p>SSH password authentication can be considered as a major security risk to servers because it is susceptible to brute-force attacks and could give anyone unauthorized access to your servers.<\/p>\n<p>For Example in AWS, SSH with pem key is the default login type for EC2 servers but Amazon&#8217;s interface only creates a single user account. In this blog, we will talk about how to setup additional pem keys which will allow you to securely login with additional users and this configuration is applicable to non-EC2 servers (either your local server or servers hosted on other public clouds) as well.<\/p>\n<p><strong>On Server :<\/strong><\/p>\n<p>First,you have to login \u00a0server using ssh with the default user account and then create a new user :-<\/p>\n<pre class=\"lang:default decode:true \">adduser myuser<\/pre>\n<p><strong>Optional<\/strong> : You have to make an entry in sudoers file if you want to assign root access to this user. Run the following command :-<\/p>\n<pre class=\"lang:default decode:true \">sudo visudo<\/pre>\n<p>Add this to the list line of the file opened :-<\/p>\n<pre class=\"lang:default decode:true\">myuser ALL=(ALL:ALL) ALL\r\n\r\n<\/pre>\n<p>To generate public and private keys for this user, run the following commands :-<\/p>\n<pre class=\"lang:default decode:true\">su - myuser\r\n\r\nssh-keygen -b 1024 -f myuser -t rsa\u00a0\r\n\r\n<\/pre>\n<p>Here, -b flag stands for number of bits, -f is for output key file name and -t defines the encryption type.<\/p>\n<p>This command will generate two key files named <strong>myuser<\/strong> and <strong>myuser.pub <\/strong>where &#8216;myuser&#8217; is your private key \u00a0and &#8216;myuser.pub&#8217; is your public key<strong>.<\/strong>\u00a0The next step is to copy public key into authorized keys. Run the following commands :-<\/p>\n<pre class=\"lang:default decode:true\">mkdir .ssh\r\n\r\ncat myuser.pub &gt;&gt; .ssh\/authorized_keys\r\n\r\n<\/pre>\n<p>Change permissions :-<\/p>\n<pre class=\"lang:default decode:true \">chmod 700 .ssh\r\n\r\nchmod 600 .ssh\/authorized_keys<\/pre>\n<p><strong>On local system :<\/strong><\/p>\n<p><strong>You will now have to download or copy the contents of \u00a0file &#8220;myuser&#8221; which is your private key file to local system<\/strong>. We&#8217;ve saved this file as myuserprivatekey.pem but remember that you can rename this file accordingly.<\/p>\n<p><strong>SSH connection to server with the new user :<\/strong><\/p>\n<pre class=\"lang:default decode:true\">ssh myuser@52.48.34.150 -i\u00a0myuserprivatekey.pem\r\n\r\n<\/pre>\n<p><span style=\"line-height: 1.5\">where\u00a0<\/span><span style=\"line-height: 1.5\">52.48.34.150 is the public IP address of EC2 instance.<\/span><\/p>\n<p><strong>SFTP access to server using filezilla :<\/strong><\/p>\n<p>In order to get SFTP access to your EC2 server for secure file transfer, you will first have to convert your private pem file to ppk file.Here, we will do so by using &#8216;puttygen&#8217; tool for which the package &#8216;putty-tools&#8217; should be installed on ubuntu. Run the following command :-<\/p>\n<pre class=\"lang:default decode:true \">apt-get install putty-tools\r\n\r\n<\/pre>\n<p><strong>To convert PEM file to PPK :-<\/strong><\/p>\n<pre class=\"lang:default decode:true \">puttygen myuserprivatekey.pem -o myuserprivatekey.ppk -O private\r\n\r\n<\/pre>\n<p>where,\u00a0myuserprivatekey.pem is your private pem key file,\u00a0myuserprivatekey.ppk is the output ppk file.<\/p>\n<p>-o Tells it where to write out the converted putty private key.\u00a0-O private Tells it that you want a putty private key (as opposed to the other output formats it can produce).<\/p>\n<p>Now, you need to simply import this file to filezilla. Select the logon mode interactive and once you supply host IP address\/name and username, you will be connected to your dedicated server and get access to all the files and directories.<\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/cloudkul.com\/contact\/\" target=\"_blank\">IN CASE OF ANY QUERY, PLEASE CONTACT US<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SSH password authentication can be considered as a major security risk to servers because it <a class=\"text-primary\" title=\"read more\" href=\"https:\/\/cloudkul.com\/blog\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":5,"featured_media":813,"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":[32,2],"tags":[38,40,39],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Securely Connecting To Server Without Password Authentication : SSH &amp; SFTP - 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\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Securely Connecting To Server Without Password Authentication : SSH &amp; SFTP - Cloudkul\" \/>\n<meta property=\"og:description\" content=\"SSH password authentication can be considered as a major security risk to servers because it [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudkul.com\/blog\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudkul\" \/>\n<meta property=\"article:published_time\" content=\"2016-02-18T06:36:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-06-14T11:34:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/02\/Connecting-Securely-to-AWS-EC2-Server-SSH-SFTP.png\" \/>\n\t<meta property=\"og:image:width\" content=\"848\" \/>\n\t<meta property=\"og:image:height\" content=\"422\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Naina Johari\" \/>\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\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/\",\"url\":\"https:\/\/cloudkul.com\/blog\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/\",\"name\":\"Securely Connecting To Server Without Password Authentication : SSH &amp; SFTP - Cloudkul\",\"isPartOf\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#website\"},\"datePublished\":\"2016-02-18T06:36:43+00:00\",\"dateModified\":\"2017-06-14T11:34:10+00:00\",\"author\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57\"},\"breadcrumb\":{\"@id\":\"https:\/\/cloudkul.com\/blog\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudkul.com\/blog\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudkul.com\/blog\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Securely Connecting To Server Without Password Authentication : SSH &amp; SFTP\"}]},{\"@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\/38f7cddff574c7fe989d6ca2df61fc57\",\"name\":\"Naina Johari\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g\",\"caption\":\"Naina Johari\"},\"url\":\"https:\/\/cloudkul.com\/blog\/author\/naina-johari379\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Securely Connecting To Server Without Password Authentication : SSH &amp; SFTP - 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\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/","og_locale":"en_US","og_type":"article","og_title":"Securely Connecting To Server Without Password Authentication : SSH &amp; SFTP - Cloudkul","og_description":"SSH password authentication can be considered as a major security risk to servers because it [...]","og_url":"https:\/\/cloudkul.com\/blog\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/","og_site_name":"Cloudkul","article_published_time":"2016-02-18T06:36:43+00:00","article_modified_time":"2017-06-14T11:34:10+00:00","og_image":[{"width":848,"height":422,"url":"https:\/\/cloudkul.com\/blog\/wp-content\/uploads\/2016\/02\/Connecting-Securely-to-AWS-EC2-Server-SSH-SFTP.png","type":"image\/png"}],"author":"Naina Johari","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/cloudkul.com\/blog\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/","url":"https:\/\/cloudkul.com\/blog\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/","name":"Securely Connecting To Server Without Password Authentication : SSH &amp; SFTP - Cloudkul","isPartOf":{"@id":"https:\/\/cloudkul.com\/blog\/#website"},"datePublished":"2016-02-18T06:36:43+00:00","dateModified":"2017-06-14T11:34:10+00:00","author":{"@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/38f7cddff574c7fe989d6ca2df61fc57"},"breadcrumb":{"@id":"https:\/\/cloudkul.com\/blog\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudkul.com\/blog\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/cloudkul.com\/blog\/securely-connecting-to-server-without-password-authentication-ssh-sftp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Securely Connecting To Server Without Password Authentication : SSH &amp; SFTP"}]},{"@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\/38f7cddff574c7fe989d6ca2df61fc57","name":"Naina Johari","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c7a0be3afff58963975900f809e57046?s=96&d=https%3A%2F%2Fs.gravatar.com%2Favatar%2F6148c37469011bc2f8e491ca8f5de495%3Fs%3D80&r=g","caption":"Naina Johari"},"url":"https:\/\/cloudkul.com\/blog\/author\/naina-johari379\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/799"}],"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\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/comments?post=799"}],"version-history":[{"count":19,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/799\/revisions"}],"predecessor-version":[{"id":815,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/posts\/799\/revisions\/815"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media\/813"}],"wp:attachment":[{"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/media?parent=799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/categories?post=799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudkul.com\/blog\/wp-json\/wp\/v2\/tags?post=799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}