The aim of this article is to demonstrate how to login to your linux box without password.
At start, there is no need for some special setup because the sshd on CentOS is already configured to allow logins with encrypted keys instead of passwords.
First, you’ll have to generate an encrypted key for the specified user (if you already don’t have one) which you will use for the login credentials, instead of the password:
ssh-keygen -t rsa
This will by default generate a 2048bit encryptd key in the /<home_directory>/.ssh/ directory, which is right where we want it. By the way, if you want some harder encryition than 2048bit, you can specify it with -b <enc_rate> e.g:
ssh-keygen -t rsa -b 4096
This will create a 4096bit RSA encrypted key. Nevertheless, it is quite safe just to leave it on default.
For a start – to make it simple, please bear in mind that this key is valid and works only for the user for which you created it (on which you are logged on at the moment of creation). If you wish to log on to your remote server with some specifically diferent user, you’ll have to create a user with that name on your local linux box and log on to that user before creating the key, and on.
To be completely honest, I mostly just do this as root, so no need for special users or any other complication on either side.
Now we only need to copy the key we created to the remote machine:
ssh-copy-id <user>@remotehost_address
Enter the <user>’s password and done.
Try ssh <remotehost_address> and it should login automatically, without asking the password