ssh password-free login

1. Check if ssh is installed

 

rpm -qa | grep ssh

 

2. Install openssh-server

 

yum install openssh-server

 

3. Start the ssh service

 

systemctl start sshd.service

 

4. Test if the service is started

 

ssh

 

5. Modify the /etc/hosts file

 

Add the lines after: ip address and hostname.

For example: ip address master

 

6. Modify the /etc/sysconfig/network file

 

Add the following two lines after:

NETWORKING=yes

HOSTNAME=master

 

7. Modify the /etc/hostname file

 

Modify the name of the machine: for example master

 

8. Use the hadoop user to perform operations to generate rsa encrypted strings

 

ssh-keygen -t rsa -P ''

cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

chmod 600 /root/.ssh/authorized_keys

 

9. Append id_rsa.pub to the authorized key

 

cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

 

10. Modify the permissions of the authorization key (note: this step is essential)

 

chmod 600 /root/.ssh/authorized_keys

 

11. Use the root user to modify the /etc/ssh/sshd_config file to comment the following three lines

 

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile.ssh/authorized_keys

 

12. Switch to hadoop user, test single-machine ssh password-free login, press the prompt to enter yes for the first time, and no prompt will be prompted the next time you log in

    

ssh master

    

If it appears: Last login: Thu Mar 10 10:26:52 2016 from master, it means that the single-machine ssh has been successfully configured

 

13. Configure ssh remote other servers:

 

1. Copy id_rsa.pub to the remote server .ssh folder and change the name to the corresponding server name.pub

 

    For example: copy from ip address to ip address 2 directory:

    scp /root/.ssh/id_rsa.pub root@ip address 2:/root/.ssh/master.pub

        

2. Copy the copied id_rsa.pub

    

For example: copy the ip address to the master.pub file of ip address 2 and append it to authorized_keys

 

cat /root/.ssh/master.pub >> /root/.ssh/authorized_keys

 

3. SSH remote other server password-free login test: 

      For example: from master to slave2 

   ssh hadoop02@slave2 

       Appears: Last login: Thu Mar 10 13:19:24 2016 from master indicates successful configuration

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326206937&siteId=291194637