Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Ssh uses the key to log in automatically. Password login is prohibited.

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Configure the private key

Host A

[root@bogon ~] # ssh-keygen-t rsa # [generate a key, generate a private key and a public key, and enter directly, then the password will not be verified when you log in to the server later, otherwise you will be required to enter passphrase

By default, the private key is placed at / root/.ssh/id_rsa and the public key is placed at / root/.ssh/id_rsa.pub.]

[root@bogon ~] # cd / root/.ssh/ # [copy the public key to the / root/.ssh/authorized_keys file on the remote server] as follows

[root@bogon ~] # scp id_rsa.pub root@10.0.250.34:/root/.ssh/authorized_keys # Note that the file name must be authorized_keys

[root@bogon ~] # scp id_rsa.pub root@10.0.250.35:/root/.ssh/authorized_keys

B mainframe

[root@bogon] # ssh-keygen-t rsa

[root@bogon ~] # cd / root/.ssh/

[root@bogon ~] # scp id_rsa.pub root@10.0.250.33:/root/.ssh/authorized_keys

C mainframe

[root@bogon] # ssh-keygen-t rsa

[root@bogon ~] # cd / root/.ssh/

The following are instructions:

1. Configure the private key

A. Use the command ssh-keygen-t rsa to generate a key, which will generate a private key and a public key. If you do not enter the key when prompted for passphrase, enter directly, then the password will not be verified later if you log in to the server, otherwise you will be asked to enter passphrase, and the private key will be placed at / root/.ssh/id_rsa public key by default

/ root/.ssh/id_rsa.pub .

Copy the public key to the / root/.ssh/authorized_keys file on the remote server

(scp / root/.ssh/id_rsa.pub server:/root/.ssh/authorized_keys), note that the file name must be authorized_keys.

C. Keep the private key on the client, and you can keep the public key or not. That is, there should be a public key on the server and a private key on the client. In this way, you can log in without password authentication.

2. If you want to maximize security and disable password login, you can modify the

Change PasswordAuthentication yes to

PasswordAuthentication no

In other words, you can only use openssh with key authentication, and password authentication is prohibited.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report