{"id":15247,"date":"2023-11-02T22:57:55","date_gmt":"2023-11-02T22:57:55","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=15247"},"modified":"2023-11-02T22:57:57","modified_gmt":"2023-11-02T22:57:57","slug":"setup-passwordless-login-to-servers-via-ssh-linux-hint","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2023\/11\/02\/setup-passwordless-login-to-servers-via-ssh-linux-hint\/","title":{"rendered":"Setup Passwordless Login to Servers via SSH \u2013 Linux Hint"},"content":{"rendered":"<p>As a Linux system administrator, you will be configuring and tweaking a lot of Linux servers frequently. So, you have to SSH into all these servers, in order to SSH into these servers, you will also need the login passwords for each of the servers, which is very unlikely to be the same. So, things will get difficult as the number of servers you have to administer grows.<\/p>\n<p>Luckily, there is a better solution. You can tell all the servers that you administer to trust the computer or laptop that you\u2019re using to connect and configure them. This way, you can log into these servers without any password or with the same password. In this method, you only need to know the login password of these servers only once. Then, you can forget about it as long as you\u2019re using the same computer or laptop to connect to these servers.<\/p>\n<p>In this article, I am going to show you how to setup passwordless login to servers via SSH. So, let\u2019s get started.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/1-10.png\" alt=\"\" width=\"801\" height=\"319\" \/><\/p>\n<p>Here, I have 3 servers on my local network linuxhint-server1, linuxhint-server2, linuxhint-server3. I as a Linux system administrator, am using a laptop linuxhint-client which is also on the same network. So, I want to configure all the servers in a way that I can access to all these servers from my laptop linuxhint-client without any password. So, let\u2019s see how this will be configured in next sections.<\/p>\n<h2>Generating SSH Keys on the Client:<\/h2>\n<p>The key idea here is that you generate an SSH key on your computer or laptop from which you want to access all the servers. Then, upload the SSH key to the servers from your computer or laptop.<\/p>\n<p>To generate an SSH key on the computer or laptop from which you want to connect to the servers, run the following command:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/2-10.png\" alt=\"\" width=\"763\" height=\"80\" \/><\/p>\n<p>Now, press &lt;Enter&gt; to continue.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/3-10.png\" alt=\"\" width=\"762\" height=\"109\" \/><\/p>\n<p>Now, you can set a password for your SSH key. It is optional. Whether you set up a password for your SSH key or not depends on how you want to configure access to the servers. If you don\u2019t set a password for the SSH key here, you won\u2019t need any password to SSH into the servers. If you do set a password here, you will need to enter the same password every time you connect to any of the servers. So, It\u2019s up to you. I will not set a password for the SSH key in this article.<\/p>\n<p>If you do want to set up a password, just type in the password and press &lt;Enter&gt;. Otherwise, leave it blank and press &lt;Enter&gt;.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/4-10.png\" alt=\"\" width=\"751\" height=\"150\" \/><\/p>\n<p>If you\u2019ve set a password earlier, just type in the same password again and press &lt;Enter&gt;. Otherwise, just press &lt;Enter&gt; without typing in anything.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/5-9.png\" alt=\"\" width=\"749\" height=\"165\" \/><\/p>\n<p>The SSH key should be generated.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/6-9.png\" alt=\"\" width=\"901\" height=\"486\" \/><\/p>\n<p>By default, the ssh-keygen generates a RSA key of length 2048 bits. But, if you want to change the key type and length, you can use the -t and -b options of ssh-keygen as follows:<\/p>\n<p>$ ssh-keygen -t key_type -b bit_length<\/p>\n<p>Currently, the supported key_type is rsa, dsa, ecdsa, and ed25519 and the bit_length can be 2048, 4096 and so on.<\/p>\n<h3>Uploading SSH Key to the Servers:<\/h3>\n<p>Now, you have to upload the SSH key you just generated on your computer or laptop to the servers. For that, you have to have SSH server software (openssh-server) installed on each of the servers and must be able to login to the servers via SSH.<\/p>\n<p>To login to linuxhint-server1 via SSH, you need the IP address of the linuxhint-server1 server. To do that, run the following command on the linuxhint-server1 server.<\/p>\n<p>As you can see, the IP address of linuxhint-server1 is 192.168.21.203.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/7-9.png\" alt=\"\" width=\"868\" height=\"307\" \/><\/p>\n<p>Now, from the linuxhint-client, upload the SSH key to the linuxhint-server1 as follows:<\/p>\n<p>$ ssh-copy-id shovon@192.168.21.203<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/8-9.png\" alt=\"\" width=\"950\" height=\"76\" \/><\/p>\n<p>Now, type in yes and press &lt;Enter&gt;.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/9-9.png\" alt=\"\" width=\"955\" height=\"133\" \/><\/p>\n<p>Now, type in the login password of the linuxhint-server1 server and press &lt;Enter&gt;.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/10-8.png\" alt=\"\" width=\"979\" height=\"221\" \/><\/p>\n<p>The SSH key should be uploaded to the server linuxhint-server1.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/11-8.png\" alt=\"\" width=\"955\" height=\"357\" \/><\/p>\n<p>The same way, upload the SSH key to the linuxhint-server2 as well.<\/p>\n<p>$ ssh-copy-id shovon@192.168.21.133<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/12-7.png\" alt=\"\" width=\"947\" height=\"339\" \/><\/p>\n<p>Upload the SSH key to the linuxhint-server3 as well.<\/p>\n<p>$ ssh-copy-id shovon@192.168.21.201<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/13-7.png\" alt=\"\" width=\"961\" height=\"351\" \/><\/p>\n<h3>SSH into Servers without Password:<\/h3>\n<p>Now, you should be able to access all the servers via SSH without any password.<\/p>\n<p>Let\u2019s try to access the server linuxhint-server1:<\/p>\n<p>$ ssh shovon@192.168.21.203<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/14-7.png\" alt=\"\" width=\"949\" height=\"74\" \/><\/p>\n<p>As you can see, it didn\u2019t prompt me for a password. Instead, I was logged in directly to the console of linuxhint-server1.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/15-7.png\" alt=\"\" width=\"995\" height=\"382\" \/><\/p>\n<p>I can also log in to the linuxhint-server2 server without any password as you can see in the screenshot below.<\/p>\n<p>$ ssh shovon@192.168.21.133<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/16-7.png\" alt=\"\" width=\"953\" height=\"115\" \/><\/p>\n<p>As you can see, I can also SSH into the linuxhint-server3 server as well. Great!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2019\/05\/17-7.png\" alt=\"\" width=\"960\" height=\"405\" \/><\/p>\n<p>So, that\u2019s how you configure passwordless login to Linux servers via SSH. Thanks for reading this article.<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/passwordless_login_ssh\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As a Linux system administrator, you will be configuring and tweaking a lot of Linux servers frequently. So, you have to SSH into all these servers, in order to SSH into these servers, you will also need the login passwords for each of the servers, which is very unlikely to be the same. So, things &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2023\/11\/02\/setup-passwordless-login-to-servers-via-ssh-linux-hint\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Setup Passwordless Login to Servers via SSH \u2013 Linux Hint&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-15247","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/15247","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=15247"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/15247\/revisions"}],"predecessor-version":[{"id":16958,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/15247\/revisions\/16958"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=15247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=15247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=15247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}