Configure SSH password-less access in Linux (RedHat6.0)

Source: Internet
Author: User

First, make sure that you have installed ssh and RedHat comes with openSSH, so you do not need to consider it.

Step 1: Use # ssh-keygen-t dsa. After using this command, you will be prompted whether to enter the password. If you do not enter the password here, you can enter it all the way, the folder is hidden in the user directory. id generated under ssh. the dsa and id_dsa.pub files are private keys and public keys respectively.

You can also directly use # ssh-keygen-t dsa-p'-f ~ /. Ssh/id_dsa, so there is no need to ask again.

There are two methods for SSH encryption: dsa and rsa. The corresponding commands are the same as-t indicating that the encryption type is dsa, and the other is rsa.

Step 2: append the public key to the authorized_keys file, which is also in the. ssh directory. It does not matter. Use # cat ~ /. Ssh/id_dsa.pub> ~ /. Ssh/authorized_keys command

Step 3: Copy authorized_keys to another machine that requires SSH password-less access (note that this is accessed, that is, if you want to access 2 from 1 without password, then you have to generate a key pair on 1 and then drop the public key on 2)

# Scp ~ /. Ssh/authorized_keys root @ (other machine ip ):/~ /. Ssh/

Scp is used to copy files from the local machine to a remote machine in linux. You can add-r to the scp to transmit folders.

Now the configuration is complete. Next we can test whether password-free access is allowed. The test method is to access the local machine first and use # ssh localhost, for the first time, you will be prompted that the accessed host cannot be connected, whether to continue the connection, enter yes, and then enter the password. After the connection is established, you can use # exit to exit. No Password is required for the connection. Similarly, you can test the connection to a remote machine (the machine where the authorized_keys file is lost). The process is the same as that of localhost. If yes, the configuration is successful.

Possible problems: in some cases, even if you perform step-by-step operations, you will not be able to achieve password-free access at the end. The possible problem may be a user problem, which I have encountered before, if you try it under a common user, the result will not work. You can replace it with the root user. Both sides use the root user.

We recommend that you use root directly for new users, saving you a lot of trouble. Do not be afraid that the root permission is too high to delete anything by mistake. Otherwise, the permission will lead to death.

I hope it will be helpful to others. I also wrote it on the Internet. Just take a note for yourself.

Complete SSH service configuration and troubleshooting in Ubuntu

Install Git, SSH, and Permission denied in Ubuntu 12.04

Offline installation of OpenSSH in Ubuntu 12.10

Install or set SSH in Ubuntu

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.