"Hadoop series" Linux root user password-free login to remote host SSH

Source: Internet
Author: User
Tags file permissions rsync

Operating Environment: CentOS 6.5

Action object: User A host and remote Host B

Body part: Italic bold represents Linux instructions.

Linux non-root user password-free login remote host SSH Please go to this link: xxxxxxxxxxxxxxxx (not yet written) One, remote Host B and user A are installed OpenSSH

First we check whether the remote host installs OPENSHH and rsync

Rpm-qa|grep OpenSSH
Rpm-qa|grep rsync

If no information is returned and the representative is not installed, we install it with the Yum command.

Yum Install Openssh-y

Yum Install Openssh-server-y

Yum Install Openssh-clients-y

Yum Install Rsync-y

(Delete openshh and rsync

Yum Remove openssh-y

Yum Remove rsync-y)

second, the user a host generates the public and private keys.

ssh-keygen-t rsa-p ' (' Default path ')

When prompted, enter to install the public and private keys in the default path. /root/.ssh/id_rsa and/root/.ssh/id_rsa.pub

third, remote Host B creates the/root/.ssh folder.

The remote host holds the path to the public and private keys in the/root/.ssh/authorized_keys file.

Because the remote host did not pass the second step, there is no/root/.ssh this folder.

The/root/.ssh folder can be obtained from the two different methods of creating a file with Linux instructions or generating a public and private key on a remote host .

⑴ through the Linux directive (this needs to consider the permissions of the folder, otherwise the user a host cannot log on to remote Host B without a password),

Here's how:

On remote Host B

⑵ performs the second step to obtain the public and private keys while obtaining the/root/.ssh folder (the benefit of doing so without considering the permissions of the folder),

Here's how:

ssh-keygen-t rsa-p ' (' Default path ')

When prompted, enter to install the public and private keys in the default path. /root/.ssh/id_rsa and/root/.ssh/id_rsa.pub

Four, the user a host's public key is still on the remote Host B.

In the third step, we obtained the/ROOT/.SSH folder on the remote Host B, and now we place the public key of the user a host under the folder, and then append it to the/root/.ssh/authorized_keys file.

/root/.ssh/authorized_keys files may not be available beforehand.

Here's how:

⑴ still public key:SCP ~/.ssh/id_rsa.pub [email protected]:~/.ssh(User a host operation)

⑵ Append to File: Cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys (remote Server B host operation)

⑶ Modify the contents of the/etc/ssh/sshd_config:

Vi/etc/ssh/sshd_config

(#RSAAuthentication Yes
#PubkeyAuthentication Yes
#AuthorizedKeysFile. Ssh/authorized_keys

Find the above 3 statements and take the previous # number off)

Note: Some articles say to/root/.ssh this folder and/root/.ssh/authorized_keys this file, you have to modify the permissions.

However, in my operation under root, if you change the/root/.ssh/authorized_keys file permissions to 600 will not be able to use password-free login, it is best to not change permissions under root.

Five, User a host password-free logon remote server B.

SSH 192.168.31.230

You can login without a password. (Exit exit)

At this point we also completed the Linux root user password-free login to the remote server.

"Hadoop series" Linux root user password-free login to remote host SSH

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.