SSH (Ssh-keygen) Configure the way to log on to a remote host without entering a password _linux shell

Source: Internet
Author: User
Tags ssh

Environment:
Local Host: HA01
ETH0:192.168.1.100//External IP address

Remote host: HA02
ETH0:192.168.1.200//External IP address

Local Host HA01 configuration:

Copy Code code as follows:

[Root@ha01/]# Cd/etc/ssh
[Root@ha01 ssh]# ssh-keygen-t rsa-n "" (This step generates a key public-private key pair,-n "" indicates that the key pair phrase is empty)
Generating public/private RSA key pair.
Enter file in which to save the key (/ROOT/.SSH/ID_RSA):
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:
82:2c:74:43:8e:16:f4:ef:ac:91:0f:d7:6f:a6:f3:59 ROOT@HA01

Copy public key to remote host (original method):
If the/root/.ssh/authorized_keys file does not exist on the HA02 server

Copy Code code as follows:

[Root@ha01 ssh]# scp/root/.ssh/id_rsa.pub Root@192.168.1.200:/root/.ssh/authorized_keys

If the Authorized_keys file exists
Execute on HA01:

Copy Code code as follows:

[Root@ha01 ssh]# scp/root/.ssh/id_rsa.pub root@192.168.1.200:/root/.ssh/

Execute on HA02:

Copy Code code as follows:

[Root@ha02/]# cat/root/.ssh/id_rsa.pub >>/root/.ssh/authorized_keys

To copy a public key to a remote host (new method):
You can use Ssh-copy-id to easily copy public keys to a remote host

Execute on HA01:

Copy Code code as follows:

[Root@ha01 ssh]# ssh-copy-id-i ~/.ssh/id_rsa.pub root@192.168.1.200

SSH Login Test:

Copy Code code as follows:

[Root@ha01 ssh]# ssh ha02
Last Login:fri APR 8 10:41:28 from HA01

Related Article

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.