{"id":1363,"date":"2020-12-31T23:23:13","date_gmt":"2020-12-31T22:23:13","guid":{"rendered":"https:\/\/codedoneright.eu\/?page_id=1363"},"modified":"2021-01-01T19:18:00","modified_gmt":"2021-01-01T18:18:00","slug":"ssh-connection","status":"publish","type":"page","link":"https:\/\/codedoneright.eu\/?page_id=1363","title":{"rendered":"SSH connection"},"content":{"rendered":"\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The below script allows for making SSH connection without the hassle of entering credentials every time. It is worth noting that, for security reasons, such script should be used only on trusted machines as you are providing login credentials in the script. <\/p>\n\n\n\n<p>This short code just saves you a few keystrokes, and combined with an <a href=\"https:\/\/codedoneright.eu\/?page_id=1045\" target=\"_blank\" rel=\"noreferrer noopener\">alias<\/a> makes your life easier if you are using SSH connection frequently.<\/p>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Required packages<\/h4>\n\n\n\n<ul><li>expect<\/li><\/ul>\n\n\n\n<p>The script makes use of <em>expect<\/em> package, it is a tool for interacting with shell in accordance with script. <\/p>\n\n\n\n<p>To install <em>expect<\/em> run the following<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install expect<\/code><\/pre>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">SSH connection script<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/expect -f\n\nspawn ssh ${USER}@${IP}\nexpect \"assword:\"\nsend \"${PASSWORD}\\r\"\ninteract<\/code><\/pre>\n\n\n\n<p>In order to automate the connection you have to change some variables. Amend the following to reflect your connection<\/p>\n\n\n\n<ul><li>${USER} \u2013 username for the server<\/li><li>${IP} \u2013 IP of the server<\/li><li>${PASSWORD} \u2013 username password<\/li><\/ul>\n\n\n\n<p><strong>Note! <\/strong>&#8220;assword:&#8221; is not a typo, as this mitigates the distinction between words &#8220;Password:&#8221; and &#8220;password:&#8221; which are in fact different.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The below script allows for making SSH connection without the hassle of entering credentials every time. It is worth noting that, for security reasons, such script should be used only on trusted machines as you are providing login credentials in&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"parent":414,"menu_order":20,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SSH connection &#8212; Code Done Right!<\/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:\/\/codedoneright.eu\/?page_id=1363\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"SSH connection &#8212; Code Done Right!\" \/>\n<meta name=\"twitter:description\" content=\"The below script allows for making SSH connection without the hassle of entering credentials every time. It is worth noting that, for security reasons, such script should be used only on trusted machines as you are providing login credentials in&hellip;\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/codedoneright.eu\/?page_id=1363\",\"url\":\"https:\/\/codedoneright.eu\/?page_id=1363\",\"name\":\"SSH connection &#8212; Code Done Right!\",\"isPartOf\":{\"@id\":\"https:\/\/codedoneright.eu\/#website\"},\"datePublished\":\"2020-12-31T22:23:13+00:00\",\"dateModified\":\"2021-01-01T18:18:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/codedoneright.eu\/?page_id=1363#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/codedoneright.eu\/?page_id=1363\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/codedoneright.eu\/?page_id=1363#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/codedoneright.eu\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\",\"item\":\"https:\/\/codedoneright.eu\/?page_id=1026\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Running script\",\"item\":\"https:\/\/codedoneright.eu\/?page_id=414\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"SSH connection\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/codedoneright.eu\/#website\",\"url\":\"https:\/\/codedoneright.eu\/\",\"name\":\"Code Done Right!\",\"description\":\"Raspberry Pi server guides\",\"publisher\":{\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/codedoneright.eu\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568\",\"name\":\"CodeDoneRight\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png\",\"contentUrl\":\"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png\",\"width\":120,\"height\":120,\"caption\":\"CodeDoneRight\"},\"logo\":{\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/codedoneright.eu\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SSH connection &#8212; Code Done Right!","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:\/\/codedoneright.eu\/?page_id=1363","twitter_card":"summary_large_image","twitter_title":"SSH connection &#8212; Code Done Right!","twitter_description":"The below script allows for making SSH connection without the hassle of entering credentials every time. It is worth noting that, for security reasons, such script should be used only on trusted machines as you are providing login credentials in&hellip;","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/codedoneright.eu\/?page_id=1363","url":"https:\/\/codedoneright.eu\/?page_id=1363","name":"SSH connection &#8212; Code Done Right!","isPartOf":{"@id":"https:\/\/codedoneright.eu\/#website"},"datePublished":"2020-12-31T22:23:13+00:00","dateModified":"2021-01-01T18:18:00+00:00","breadcrumb":{"@id":"https:\/\/codedoneright.eu\/?page_id=1363#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codedoneright.eu\/?page_id=1363"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/codedoneright.eu\/?page_id=1363#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codedoneright.eu\/"},{"@type":"ListItem","position":2,"name":"Linux","item":"https:\/\/codedoneright.eu\/?page_id=1026"},{"@type":"ListItem","position":3,"name":"Running script","item":"https:\/\/codedoneright.eu\/?page_id=414"},{"@type":"ListItem","position":4,"name":"SSH connection"}]},{"@type":"WebSite","@id":"https:\/\/codedoneright.eu\/#website","url":"https:\/\/codedoneright.eu\/","name":"Code Done Right!","description":"Raspberry Pi server guides","publisher":{"@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codedoneright.eu\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568","name":"CodeDoneRight","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/","url":"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png","contentUrl":"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png","width":120,"height":120,"caption":"CodeDoneRight"},"logo":{"@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/codedoneright.eu"]}]}},"_links":{"self":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/1363"}],"collection":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1363"}],"version-history":[{"count":7,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/1363\/revisions"}],"predecessor-version":[{"id":1434,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/1363\/revisions\/1434"}],"up":[{"embeddable":true,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/414"}],"wp:attachment":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}