{"id":6853,"date":"2022-09-02T14:04:26","date_gmt":"2022-09-02T08:34:26","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=6853"},"modified":"2022-09-02T14:06:13","modified_gmt":"2022-09-02T08:36:13","slug":"setting-up-passwordless-ssh-and-alias-for-remote-login-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/setting-up-passwordless-ssh-and-alias-for-remote-login-ubuntu-18-04\/","title":{"rendered":"<strong>Setting Up Passwordless SSH and Alias For Remote Login &#8211; Ubuntu 18.04<\/strong>"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><br>We will be able to ssh from one remote-1 machine into another remote-2 machine without typing its IP and the password in the terminal.<br><br><strong>Prerequisite<\/strong><br><br>A user with sudo privileged access to the remote servers<br><br><strong>Implementation<\/strong><br><br>1. Log in to a remote-1&nbsp; server<br><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>ssh user@ip<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><br>2. As a root user run the below command to add the remote-1 server key to the remote-2 server to log in without a password<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>ssh-copy-id user@remote-2 IP<br>===<br>Provide the required password<br>===<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">3. Log in to a remote-2 server and edit the sudoers file<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>vi \/etc\/sudoers<br><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">5. Copy and paste the below line under the section #includedir \/etc\/sudoers.d  to avoid entering the password while doing sudo su<br><br>Then save and exit from the file<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>user ALL=(ALL) NOPASSWD: ALL<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><br>7. In the remote-1 server under as a root user, add the alias in the .bashrc file<br><br><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>cd \/root<br>vi .bashrc<br><br>====<br>Copy and paste the below line. Modify the IP and name accordingly without adding space<br>====<br><br>alias name=&#8217;ssh user@remote-2 IP&#8217;<br><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><br>8. Then execute the .bashrc script with the below command<br><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>source ~\/.bashrc<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">9. Then try to access the remote-2 server with the alias name from the remote-1 server, we should able to log in without password and IP address<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We will be able to ssh from one remote-1 machine into another remote-2 machine without typing its IP and the [&hellip;]<\/p>\n","protected":false},"author":495,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[960],"class_list":["post-6853","post","type-post","status-publish","format-standard","hentry","category-web-architecture","tag-passwordless-ssh","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-1Mx","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6853","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/495"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=6853"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/6853\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=6853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=6853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=6853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}