To resolve the request for password after SSH configuration without password login

Source: Internet
Author: User
Tags scp command

http://inuyasha1027.blog.51cto.com/4003695/1132896/

Host ip:192.168.163.100 (HOSTNAME:NODE0)

SSH remote machine ip:192.168.163.101 (hostname:node1) without password login

The first step is to modify the configuration file of the remote machine to which the host and SSH are connected:

Vi/etc/ssh/sshd_config

(to ensure that these characters have no comment symbol "#" before them)

Rsaauthentication Yes

Pubkeyauthentication Yes

Authorizedkeysfile. Ssh/authorized_keys

Passwordauthentication Yes

Peimitemptypasswords Yes

1. Enter the command on the local machine: ssh-keygen-t RSA

2. Then press ENTER, by default, the public key generated by SSH is stored in the

/root/.ssh

This folder is Id_rsa and Id_rsa.pub, respectively.

PS: If a Hadoop user logs in because the Hadoop user initially logs in to the directory that is the root of the Hadoop user, then do it under Home/hadoop, which is the difference between root/.ssh and home/hadoop/.ssh on the web.

3. Create a file on the local machine Authorized_keys

Touch/root/.ssh/authorized_keys

and append the public key to the Authorized_keys file:

Cat Id_rsa.pub >> Authorized_keys

4. Create the folders and files on the remote host as follows:

/root/.ssh/authorized_keys

5. Modify the permissions of the folder/root/.ssh:

(both local and remote machines have to be modified)

chmod 700/root/.ssh

6. Modify the properties of the file:

chmod 600/root/.ssh/authorized_keys

7. Copy the public key to the remote machine with IP address 192.168.163.101:

Ssh-copy-id-i/root/.ssh/id_rsa.pub [email protected]

I have created a folder and a file on the remote host when I entered the command as follows:

/root/.ssh/authorized_keys

Also, permissions have been modified as described above/.ssh (/.ssh/authorized) (600)

(Practice proves that this command is better than the SCP command when transferring the public key)

8. Execute the command on the local machine:

Ssh-add/root/.ssh/id_rsa

This is to add the public key in.

9. Restart the SSH service:

Service sshd Restart

10. On the local host, enter:

SSH node1 (carriage return)

Can log on to the remote host.

PS: Folder path or file name varies according to individual configuration,

Changes need to be made according to specific circumstances.

Do not modify permissions and do not execute Ssh-add command for folders and files

Causes a password to be entered after the remote login is set.

Of course, you should also pay attention to the configuration file settings and modifications.

Good luck ~

================================================================

There are several ways to copy the public key to the server's ~/.ssh/authorized_keys file:
1, the public key through the SCP copy to the server, and then appended to the ~/.ssh/authorized_keys file, this way is more troublesome. Scp-p ~/.ssh/id_rsa.pub [email protected]:~/.
2, through the Ssh-copyid program, is my demonstration method, Ssh-copyid [email protected] can, but this way does not support changing the port number (I did not find). The program common release version of Linux comes with no installation, in fact the program is a script.
3. Can be ~/.ssh/id_rsa.pub by cat | ssh-p [email protected] ' cat >> ~/.ssh/authorized_keys ', this is also a more common method, because you can change the port number.

To resolve the request for password after SSH configuration without password login

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.