{"id":7503,"date":"2019-10-29T13:00:15","date_gmt":"2019-10-29T13:00:15","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=7503"},"modified":"2021-11-16T05:30:20","modified_gmt":"2021-11-16T05:30:20","slug":"terraform-error-failed-to-read-ssh-private-key-no-key-found","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/terraform-error-failed-to-read-ssh-private-key-no-key-found\/","title":{"rendered":"Terraform Error: Failed to read ssh private key: no key found"},"content":{"rendered":"<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\">\n provisioner <span class=\"hljs-string\">\"file\"<\/span> {\n  source      = <span class=\"hljs-string\">\"index.html\"<\/span>\n  destination = <span class=\"hljs-string\">\"\/tmp\/index.html\"<\/span>\n\n  connection {\n    type     = <span class=\"hljs-string\">\"ssh\"<\/span>\n    user     = <span class=\"hljs-string\">\"ec2-user\"<\/span>\n    private_key = <span class=\"hljs-string\">\"id_rsa\"<\/span>\n    host = <span class=\"hljs-string\">\"self\"<\/span>\n  }\n}\naws_instance.web: Provisioning <span class=\"hljs-keyword\">with<\/span> <span class=\"hljs-string\">'file'<\/span>...\nTerraform <span class=\"hljs-built_in\">Error<\/span>: Failed to read ssh private key: no key found<\/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<p><strong>Solutions<\/strong><\/p>\n\n\n\n<p>private_key &#8211; The contents of an SSH key to use for the connection. These can be loaded from a file on disk using the file function. This takes preference over the password if provided.<\/p>\n\n\n\n<p>private_key\u00a0=\u00a0&#8220;file(\/Users\/rajeshkumar\/.ssh\/id_rsa)&#8221;<\/p>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_90016\"><iframe loading=\"lazy\"  id=\"_ytid_67166\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?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__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_90016\"  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><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Solutions private_key &#8211; The contents of an SSH key to use for the connection. These can be loaded from a file on disk using the file function. This takes preference&#8230; <\/p>\n","protected":false},"author":1,"featured_media":7794,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5129],"tags":[],"class_list":["post-7503","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-terraform"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/7503","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=7503"}],"version-history":[{"count":4,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/7503\/revisions"}],"predecessor-version":[{"id":25348,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/7503\/revisions\/25348"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/7794"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=7503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=7503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=7503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}