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 password-free login configuration operation

2025-01-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

I) generate public and private keys locally

1) [root@SamuluIndex ~] # cd .ssh

2) [root@SamuluIndex .ssh] # rm-f * (clear all old files in the .ssh directory)

3) [root@SamuluIndex .ssh] # ssh-keygen. Press enter in three places that need to be entered in the process.

Id_rsa and id_rsa.pub are generated in the .ssh directory. Where id_rsa is the private key, which is used by the local machine, and id_rsa.pub is the public key, which is used by other machines.

(2) upload the public key to the remote host

[root@SamuluIndex .ssh] # scp id_rsa.pub root@172.20.0.141:/root/.ssh

After you are prompted to enter the password for the remote host (172.20.0.141), you can see the prompt for a successful upload:

Id_rsa.pub 100% 398 0.4KB/s 00:00

(3) Log in to the remote host and write the client public key to the authorized_keys file

[root@SamuluIndex .ssh] # ssh 172.20.0.141

Warning: Permanently added '172.20.0.141' (RSA) to the list of known hosts.

Root@172.20.0.141's password:

Last login: Tue Apr 29 21:09:27 2014 from 192.168.0.56

[root@tixa ~] # cd .ssh

[root@tixa .ssh] # cat id_rsa.pub > > authorized_keys

At this point, you can see two files, authorized_keys and id_rsa.pub, in the .ssh directory of the 141machine. The main purpose of id_rsa.pub is to write public key information into authorized_keys. Then delete the id_rsa.pub from both hosts, otherwise the machine will not be able to log in to other machines without a password.

(4) exit the remote host and log in to the remote host again

At this point, it is found that you can log in to remote machine 141 without a password on 100 machines.

And two files are kept in .ssh on the100th machine: id_rsa and known_hosts, and one file in .ssh on the141machine: authorized_keys.

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

Network Security

Wechat

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

12
Report