docker compose
Docker compose : Install from ec2 userdata
March 26, 2018

How to setup password less login on Linux

SSH gives secure remote connection to the remote systems. It is used commonly in Linux and systems administration area. We can duplicate keys to remote and local systems by means of ssh in a safe way. Keeping in mind the end goal to make things clear we can utilize password less key based login for ssh convention.

Step #1: Generate an ssh key

The keys are to be created on each host that wish to gain access from. So, if there are several hosts from where to access a server, we must create keys on all those servers.

To create keys, run the following command:

$ ssh-keygen –t rsa

By default, the keys will be stored in the ~/.ssh which is a hidden directory in your home folder (/home/user/.ssh). The private key will be called id_rsa and the associated public key will be called id_rsa.pub.
It will likewise request that you enter a passphrase, which is utilized to decrypt the keys. On the off chance that you don’t wish to utilize any passphrase simply ignore it and press enter or else give a pass-phrase.

Next, set permissions on your private keys


$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/id_rsa

Step #2: Copy the public key to the remote server

Now copy the Public key (id_rsa.pub) & move it to remote server at /home/user/.ssh/authorized_keys folder. Now that the public keys have imported to the remote server, remove them from the local machine.

Next, we will also have to set permissions on the server as well


$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/authorized_keys

All the settings for Public/Private keys authentication are now complete.

Step #3: Test the connection

Now log back into the local machine to access server & enter

$ ssh {Server IP address or FQDN}

& hit enter. You will notice that you won’t be asked for the credentials & are logged directly into the server.

Step #4(Optional): Disable password login

Once you have tested your Public/Private keys authentication, you can also disable use of password authentication so that everyone uses only keys to access the server. Thus making your servers more secure. To disable password authentication , open/etc/sshd/sshd_config & change the following parameter

PasswordAuthentication no

That’s all, Public/Private keys authentication setup is now complete.

If you have any comments/queries, please mention them in the comment box down below.

Bitnami