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

What is the operation procedure of MacOs secret-free login CentOs

2025-06-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

What is the operation procedure of MacOs secret-free login CentOs? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

MacOs secret-free login to CentOs

Environment

The operation environment of this article is as follows:

CentOs 7MacOs10.12.6

Generate secret key

First, generate the secret key on the local machine, open the terminal, and type:

Ssh-keygen-t rsa-C xxxxx@qq.com

The mailbox in the back is at will.

Then press enter all the time, and at the end of execution, a hidden .ssh folder is generated under the current user's root directory.

Let's take a look at this folder

WangjianfengdeiMac:~ wangjianfeng$ cd / .sshwangjianfengdeiMac:.ssh wangjianfeng$ lsid_rsa id_rsa.pub known_hostswangjianfengdeiMac:.ssh wangjianfeng$

As you can see, three files are generated, in which id_rsa is the private key file, id_ras.pub is the public key file, and the known_hosts file is ignored.

Upload key

Execute the command in the ssh directory:

Cat id_rsa.pub > authorized_keys

Copy the contents of the public key to authorized_keys.

Next, log in to the remote server and create a .ssh folder

WangjianfengdeiMac:.ssh wangjianfeng$ ssh root@xxx.xxx.xxx.xxxroot@xxx.xxx.xxx.xxx's password:Last login: Sat Mar 3 15:03:08 2018 from xx.xx.xx.xxx [root @ VM_0_14_centos ~] # mkdir ~ / .ssh

After logging out, copy the authorized_key to the .ssh directory on the server through scp

WangjianfengdeiMac:.ssh wangjianfeng$ scp authorized_keysroot@xxx.xxx.xxx.xxx: / root/.ssh/authorized_keysroot@xxx.xxx.xxx.xxx's password:authorized_keys 100% 394 73.1KB/s 00:00

Then try to log in to the remote service:

There are two possible situations:

Login success: indicates that the configuration is successful and a password is required to log in successfully.

If you need a password to log in, the configuration has not yet taken effect. Try using the following steps:

Log in to the server to check the file permissions of the .ssh directory and authorized_keys

.ssh should be 700 authorizedauthorized keys should be 600

Modify it with the following command

Chmod 700. sshchmod 60000. ssh/authorized_keys

If the above actions are not successful, run the following command to see the cause of the failure:

Tail / var/log/secure-n 20

This is the answer to the question about the operation procedure of MacOs secret-free login CentOs. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

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

Development

Wechat

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

12
Report