{"id":175,"date":"2022-07-27T11:44:00","date_gmt":"2022-07-27T11:44:00","guid":{"rendered":"https:\/\/www.mitango.app\/?p=175"},"modified":"2024-11-12T11:47:52","modified_gmt":"2024-11-12T11:47:52","slug":"stop-losing-your-ssh-information","status":"publish","type":"post","link":"https:\/\/www.mitango.app\/fr\/2022\/07\/27\/stop-losing-your-ssh-information\/","title":{"rendered":"Stop losing your SSH information"},"content":{"rendered":"<p><a href=\"https:\/\/medium.com\/@crochetfeve0251?source=post_page---byline--b7fd6e5e66b5--------------------------------\" target=\"_blank\" rel=\"noopener\"><\/a><\/p>\n\n\n\n<p id=\"a175\">Did you already lost hours because you lost your information to connect to a server after months not using it?<\/p>\n\n\n\n<p id=\"91ce\">If it is the case what we will detail in this article will interest you for sure and make you save time for sure.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1536\">The problem<\/h2>\n\n\n\n<p id=\"f81a\">Most of time, as a developer we have multiple servers we have to interact with. However our brain has limited capacities and this can rapidly become a mess when we have to interact with server we didn\u2019t worked with since a week or a month.<\/p>\n\n\n\n<p id=\"ecf7\">Often the IP of the server is lost in a mountain of commands and it can be even worse for the key used to connect to the server which can be lost somewhere on the filesystem.<\/p>\n\n\n\n<p id=\"cb74\">This two problems are a certainly small but really repetitive and over a year it is hours to days you are loosing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ea4c\">Giving to the IP a name<\/h2>\n\n\n\n<p id=\"7c20\">The first problem we will be solving is the problem with the IP of the server.<\/p>\n\n\n\n<p id=\"6775\">What we will do is that we will give it a name that we can remember later.<\/p>\n\n\n\n<p id=\"7fad\">For that we will have to edit the file&nbsp;<strong><em>\/etc\/hosts<\/em><\/strong>&nbsp;and add this line where:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><em>xxx.xxx.xxx.xxx<\/em><\/strong>\u00a0is your IP.<\/li>\n\n\n\n<li><strong><em>server_name<\/em><\/strong>\u00a0is the name you want to give it.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code is-style-light\"><code>xxx.xxx.xxx.xxx  server_name<\/code><\/pre>\n\n\n\n<p id=\"d3d9\">Once we have set this now instead of using the ip in our ssh command we can use the name we gave it which is a way easier to remember.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4148\">Saving login details<\/h2>\n\n\n\n<p id=\"7df8\">The second thing to do is to find a way to remember our key everytime we connect to the server.<\/p>\n\n\n\n<p id=\"f99e\">For that we will use ssh configuration file which will help us to set a default password for the server.<\/p>\n\n\n\n<p id=\"7d6f\">For that we will have to add content or create ~\/.ssh\/config.<\/p>\n\n\n\n<p id=\"cfd8\">To connect to the server then you add the following content:<\/p>\n\n\n\n<pre class=\"wp-block-code is-style-light\"><code>Host server_name<br>   HostName server_name<br>   User root<br>   Port 22<br>   IdentityFile ~\/server_name.pem<\/code><\/pre>\n\n\n\n<p id=\"d94c\">Where:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><em>server_name<\/em><\/strong>\u00a0is the name or the IP of the server.<\/li>\n\n\n\n<li><strong><em>~\/server_name.pem<\/em><\/strong>\u00a0is the path to the key to connect to the server.<\/li>\n<\/ul>\n\n\n\n<p id=\"8a32\">Now that you know this you won\u2019t have anymore to search for your login when you have to connect to a server by SSH.<\/p>\n\n\n\n<p id=\"8e5f\">I hope you enjoyed this tutorial and it will be useful for you in the future.<\/p>","protected":false},"excerpt":{"rendered":"<p>Did you already lost hours because you lost your information to connect to a server after months not using it?<\/p>\n<p>If it is the case what we will detail in this article will interest you for sure and make you save time for sure.<\/p>","protected":false},"author":1,"featured_media":176,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[39],"tags":[43,41,44,40,42],"class_list":["post-175","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux","tag-servers","tag-software-engineering","tag-ssh","tag-tutorial"],"jetpack_publicize_connections":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.mitango.app\/fr\/wp-json\/wp\/v2\/posts\/175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mitango.app\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mitango.app\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mitango.app\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mitango.app\/fr\/wp-json\/wp\/v2\/comments?post=175"}],"version-history":[{"count":1,"href":"https:\/\/www.mitango.app\/fr\/wp-json\/wp\/v2\/posts\/175\/revisions"}],"predecessor-version":[{"id":177,"href":"https:\/\/www.mitango.app\/fr\/wp-json\/wp\/v2\/posts\/175\/revisions\/177"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mitango.app\/fr\/wp-json\/wp\/v2\/media\/176"}],"wp:attachment":[{"href":"https:\/\/www.mitango.app\/fr\/wp-json\/wp\/v2\/media?parent=175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mitango.app\/fr\/wp-json\/wp\/v2\/categories?post=175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mitango.app\/fr\/wp-json\/wp\/v2\/tags?post=175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}