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

Centos configuration ssh password-free login still need to enter password solution

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Preface

When building the Linux cluster service, the master server needs to start the slave server service. If it is started manually, several servers in the cluster will be fine. If it is like Ali's 1000 ladder Hadoop cluster, it will take several engineers a day or two for the track to start the cluster. Isn't that scary? If you use secret-free login, the master server can execute the startup steps through the program, which will automatically help us to start the application from the server. All this is based on the password-free login of the ssh service. So to learn about cluster deployment, you must understand linux's password-free login.

Step 1: create a secret key on this machine

1. Execute the command:

Ssh-keygen-t rsa-C "xx@qq.com"

(casually make up a string, usually use a mailbox)

2. Enter all the way after that; a .ssh (hidden) folder will be generated in the ~ (home) directory.

3. There are two files, id_rsa (private key) and id_rsa.pub (public key).

Note:

① in the liunx environment, if you want to copy a public key or a private key, do not use an editor such as vim to open a file to copy and paste

Because it will produce unnecessary carriage returns.

② should use cat to print the content to the terminal before copying and pasting.

Step 2: copy the public key to the remote host with ssh-copy-id

Ssh-copy-id zhangming@192.168.161.132

Copy the key to the remote server

The port used for copying in this way is 22 by default in Linux. If you want to specify a port, you can use:

Ssh-copy-id-I / username / .ssh/id_rsa.pub'- p port number username @ 106.75.52.44'

Ssh-copy-id-I / root/.ssh/id_rsa.pub'- p 22222 root@106.75.52.44'

It may take a while to wait here, anyway, I have been waiting for a long time, and then it shows that I want you to enter your password:

Zhangming@106.75.52.44's password:

After entering the password, it displays:

Now try logging into the machine, with "ssh'- p 22222 root@106.75.52.44'", and check in:

.ssh / authorized_keys

To make sure we haven't added extra keys that you weren't expecting.

It means it worked!

Step 3: log in remotely

[zhangming@localhost ~] $ssh zhangming@192.168.161.134Last login: Mon Oct 10 14:18:54 2016 from 192.168.161.135ssh zhangming@123.59.44.56-p 22222

Be careful

The big pit encountered:

After configuring ssh password-free login, you will still be prompted for a password

Solution:

First of all, we need to check the log files of the system.

Tail / var/log/secure-n 20

Discover the problem: Authentication refused: bad ownership or modes for file

Literally, we can see that it is the owner of the directory and the improper configuration of permissions. Looking up the information, we know that SSH does not want the home directory and ~ / .ssh directory to have write permission to the group, so change it through the following commands

Chmod Gmurw / home/zhangming chmod 700 / home/zhangming/.sshchmod 600 / home/zhangming/.ssh/authorized_keys

Then we can log in again and get in without a password.

Are you very happy?

Summary

The above is the whole content of this article, I hope that the content of this article can bring some help to your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.

Reference: [http://blog.csdn.net/u013066244/article/details/52796341]

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