IAMEM Hosting

CentOS Key Based SSH Login

Home > Blog > Debian > CentOS Key Based SSH Login
09Aug, 2016

CentOS Key Based SSH Login

SSH Key based authentication is very useful for transferring data and for some data sync applications to work, to configure the key based login on a CentOS Server

1. Generate SSH Key pair by running

[root@localhost ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
5b:9c:74:08:15:4a:13:13:cb:15:ff:c2:f6:d8:0b:d3 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|        B+=o     |
|       o B o     |
|        + o o    |
|         o + .   |
|        S + + .  |
|         o . *   |
|        .   + E  |
|             o . |
|              .  |

Passphrase for the key is optional and you can leave it blank.

2. Once the key pair is generated copy it to the remote server using

[root@localhost ~]# ssh-copy-id -i /root/.ssh/<PUBFILE>.pub [email protected]
The authenticity of host ' (' can't be established.
RSA key fingerprint is 5c:3a:99:15:46:a6:56:1c:66:5c:1e:ed:ea:76:a3:cd.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (RSA) to the list of known hosts.
[email protected]'s password:

3. Once the key is copied successfully, you can start logging into the server by just login using

ssh [email protected]

4. If the other server is running SSH service on a different port other that the default (22) you need to copy the ssh key as below

ssh-copy-id -i /root/.ssh/<FILENAME>.pub "[email protected] -p 2232"


Leave a Reply

nine + 10 =

Copyright © 2019 | iamemhost.com . All rights reserved.