SSH passwordless Login Using ssh Keygen in 5 easy Steps

Source: Internet
Author: User
Tags secure copy ssh keygen

SSH (Secure SHELL) is a open source and most trusted network protocol, is used to login into remote servers for EXECU tion of commands and programs. It is also used to transfer files from one computer to another computer over the network using secure Copy (SCP) Protocol.

In this article we'll show you how to setup password-less login on Rhel/centos 7.x/6.x/5.x and Fedora usingssh keys to C Onnect to remote Linux servers without entering password. Using password-less login with SSH keys would increase the trust between the Linux servers for easy file synchronization or Transfer.


Setup SSH passwordless Login

My Setup Environment
SSH client:192.168.0.12 (Fedora) SSH Remote host:192.168.0.11 (CentOS 7)

If you were dealing with number of Linux remotes servers, then SSH password-less Login was one of the best automate TA SKS such as automatic backups with scripts, synchronization files using SCP and remote command execution.

In this example we'll setup SSH password-less automatic login from server 192.168.0.12 as user Tecmint to192.168.0.11 WI Th user Sheena.

Step 1:create authentication Ssh-kegen Keys on– (192.168.0.12)

First login to server 192.168.0.12 with the user tecmint and generate a pair of public keys using following command.

[Email protected] ~]$ ssh-keygen-t rsagenerating public/private RSA key pair. Enter file in which to save the key (/HOME/TECMINT/.SSH/ID_RSA): [Press Enter key]created directory '/home/tecmint/.ssh '. E Nter passphrase (empty for no passphrase): [press ENTER Key]enter same passphrase again: [Press ENTER Key]your Identificat Ion has been saved In/home/tecmint/.ssh/id_rsa. Your public key have been saved in/home/tecmint/.ssh/id_rsa.pub.the key fingerprint Is:5f:ad:40:00:8a:d1:9b:99:b3:b0:f8 : 08:99:c3:ed:d3 [email protected]the key ' s randomart image is:+--[RSA 2048]----+|        . oooe.++| |         O. o.o         | | O.  . o| |        S.  . + ||       . .    . o| |      . o O.    . | |       + +       ||        +.       | +-----------------+

Create SSH RSA Key

Step 2:create. SSH Directory on–192.168.0.11

Use SSH from server 192.168.0.12 to connect server 192.168.0.11 using Sheena as user and create. Sshdirectory under it, US ing following command.

[[email protected] ~]$ ssh [email protected] mkdir-p. sshthe authenticity of host ' 192.168.0.11 (192.168.0.11) ' can ' t be Established. RSA key fingerprint is 45:0e:28:11:d6:81:62:16:04:3f:db:38:02:la:22:4e. Is you sure want to continue connecting (yes/no)? yeswarning:permanently added ' 192.168.0.11 ' (ECDSA) to the list of known hosts. [email protected] ' s password: [Enter Your password here]

Create SSH Directory under User Home

Step 3:upload Generated Public Keys to–192.168.0.11

Use SSH from server 192.168.0.12 and upload new generated public key (id_rsa.pub) on server 192.168.0.11under Sheena ' s. SS H directory as a file name Authorized_keys.

[email protected] ~]$ Cat. Ssh/id_rsa.pub | SSH [email protected] ' cat >> ssh/authorized_keys ' [email protected] ' s password: [Enter Your password here]

Upload RSA Key

Step 4:set Permissions on–192.168.0.11

Due to different SSH versions on servers, we need to set permissions on. SSH directory and Authorized_keys file.

[[email protected] ~]$ ssh [email protected] "chmod. SSH; chmod 640 Ssh/authorized_keys "[email protected] ' s password: [Enter Your password here]

Set Permission on SSH Key

Step 5:login from 192.168.0.12 to 192.168.0.11 Server without Password

From now onwards you can log into 192.168.0.11 as Sheena user from server 192.168.0.12 as Tecmint user without password.

[[email protected] ~]$ ssh [email protected]

SSH Remote passwordless Login

SSH passwordless Login Using ssh Keygen in 5 easy Steps

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.