Centos (6) ssh automatic login configuration

Source: Internet
Author: User
This article is based on centos (4) iptables's LAN environment, and configures ssh Automatic Logon for multiple machines in the LAN. There are already a lot of ssh configuration files on the network. This article also uses the same method, mainly to analyze and sort out some problems encountered, hope to be useful to yourself and others. First

This article is based on centos (4) iptables's LAN environment, and configures ssh Automatic Logon for multiple machines in the LAN. There are already a lot of ssh configuration files on the network. This article also uses the same method, mainly to analyze and sort out some problems encountered, hope to be useful to yourself and others. First

This article is inCentos (4) iptables build LAN environmentOn the basis of ssh automatic login configuration for multiple machines in the LAN.

There are already a lot of ssh configuration files on the network. This article also uses the same method, mainly to analyze and sort out some problems encountered, hope to be useful to yourself and others.

First, ssh-keygen is used to generate the public key and private key on the johnny-test-3 machine.

Then, use ssh-copy-id to copy the file to another machine:

The next step is to copy the/etc/ssh/ssh_config file ~ In the/. ssh/directory, name it config. If you use the default id_dsa, skip this step.

Then you can directly ssh to the johnny-test-2 machine.

Let's compare the content of authorized_keys and test3_dsa.pub on the johnny-test-2 machine, and we will find that they are actually the same.

Therefore, ssh-copy-id does two things: first, the local *. pub file of scp is uploaded to the target machine, and then cat *. pub> authorized_key is used.

Currently, there are three machines in the LAN. To allow any two machines to log on automatically, you only need to set the authorized_key file on one server, copy the file directly to all other machines.

I encountered a strange problem again. johnny-test-1 can be connected to other machines, and other machines can automatically log on to each other, but they cannot automatically log on to johnny-test-1.

Now we need to check the ssh log and use the root permission To view/var/log/secure. The following error will be found:

Next, compare johnny-test-1 ~ /. Ssh and other machine's ~ /. Ssh directory has the following permissions: too many. ssh directory permissions for johnny-test-1 will be found,

Johnny-test-1

Other machines

Use the following command:

Chmod 700 ~ /. Ssh

From other machines, we can automatically ssh to johnny-test-1.

Solve this problem

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.