Troubleshooting SSH password-less login unsuccessful

Source: Internet
Author: User

Setting up SSH to login without password is simple and takes only two steps:

1. Create a public and private key locally:

Ssh-keygen -t RSA

2. Then upload the public key to the remote machine:

ssh-copy-ID -I. ~/. SSH 192.168.41.132

Under normal circumstances, the two-step setup can be no password login:

SSH 192.168. 41.132

But the problem is still to enter the password, online find information, have said to Restorecon , also said to chmod , finally found the problem in /var/log/audit/audit.log :

cat /var/log/audit/audit.log ... TYPE=AVC Msg=audit (1417198093.916:14807): avc:denied {search} for pid=1977 comm= "sshd" name= "/" DEV=VDB1 ino=2 S context=system_u:system_r:sshd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:file_t:s0 tclass=dir ...

The error in avc:denied {search} is reported here, which is a selinux security issue, and the workaround is to:

1. Copy the error line from the /var/log/audit/audit.log file to the temporary file /tmp/error.txt :

grep " AVC:  denied  {search}" /var/log/audit/audit.log >/tmp/error.txt

2. Execute the following command to let the system find its own reasons:

# audit2why-i/tmp/error.txttype=avc msg=audit (1417198093.916:14807 for pid= 1977 comm="sshd" name="/" dev=vdb1 ino=2 scontext=system_u:system_r:sshd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:file_t:s0 tclass=dir was caused by:missing type Enforcement (TE) to allow rule. You can use the Audit2allow to generate a loadable module to the this access.

3, according to the above command output description, execution:

# audit2allow-i/tmp/error.txt-M local******************** IMPORTANT ***********************   Make-I local.pp

4, according to the above command output description, execution:

Semodule-i local.pp

This resolves the avc:denied {search} problem.

After solving this problem, SSH login still needs to enter the password. For this, we also looked at the tail of the /var/log/audit/audit.log file, newly found avc:denied {getattr} error, the solution with the above 1-4 steps. After resolving these two errors, you can login without a password.

Troubleshooting SSH without password logon is unsuccessful

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.