SSH password-free login on Linux

Source: Internet
Author: User

Due to the need for work, the need to frequently publish the system, so decided to make a set of automatic upload files on the publishing machine, remote run script automation release, but each time ssh need to enter a password, so you need the SSH password-free login mentioned in this article.

Existing a servers and B servers, a server requires SSH password-free connection to the B server.

The following command on Server B first creates the. SSH directory under the user directory and creates a public and private key (Id_rsa,id_rsa.pub) under it:

Ssh-keygen-t Rsa-p '

Then for testing convenience, first import your own public key into the trusted public key list

CD ~/.sshcat id_rsa.pub >> Authorized_keys

This is done, and now it's time to test the side-error

Connect yourself to verify whether the success

SSH localhost

The first connection will have a prompt, whether to join the trusted host file, enter Yes.

If you do not prompt for a password, you will be successful if you need to enter a password to indicate where there is a problem.

Summarize the next 3 places that may cause SSH password-free logon failures.

    • . SSH permissions: This is the most common problem, although the creation of files on the RHEL6 default is 644 of the permissions, without change, the single does not exclude other Linux distributions, the. SSH folder requires 700 permissions, Authorized_ The keys need to be 644 or 600 (600 is more secure to keep other users from viewing it. )

chmod Sshchmod 644 Authorized_keys
    • User Directory permissions: The folder directory permission of the password-free login user must be 755

ll ~/.
    • The last, and most difficult to find, is that only the root user can login with no password, no other users, even if the above permissions are configured correctly, it is not shutdown SELinux

Vim/etc/selinux/config changed selinux=enforcing to selinux=disabled.

This is a permanent change, but requires a restart to take effect, if it is to take effect immediately, then you need to run the temporary effective command

Setenforce 0


After this 3-step troubleshooting, you should be able to solve the vast majority of SSH problems, in addition, if you encounter problems, the best way is to look at the system security log

Tail-f/var/log/secure

Or use the SSH debug mode connection to see where the problem is.

Ssh-v debug localhost (or other host)


If the machine is normal, then a repeat of the first step, a id_rsa.pub added to the B Authorized_keys can be.


This article is from the "Scar of Lightning" blog, make sure to keep this source http://glennxie.blog.51cto.com/1267825/1660720

SSH password-free login on Linux

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.