当前位置:网站首页>SSH login without password

SSH login without password

2022-06-29 03:24:00 se7en_ q

One 、 Environmental Science

operating system :CentOS

Clustered ip:192.168.241.130 hadoopnamenode

192.168.241.131 hadoopdatanode1

192.168.241.132 hadoopdatanode2

user :root, Others can be

   ssh stay ~/.ssh perhaps /root/.ssh Under the directory of

Two 、 If you're starting hadoop When clustering, there are reports The authenticity of host 'localhost (127.0.0.1)' can't be established. That means you ssh Login without password failed , therefore , The cluster cannot be run normally .

1、 To configure hadoopnamenode(hadoopdatanode1|hadoopdatanode2 With hadoopnamenode For example ) Login without password localhost

a、 Get the key pair :

[email protected]:~# ssh-keygen -t rsa Or is it ssh-keygen( If your ssh Directory is id_rsa Words )

Generating public/private rsa key pair.

Enter file in which to save the key (/home/hadoop/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/hadoop/.ssh/id_rsa.

Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.

The key fingerprint is:

c8:5e:3e:c1:9b:52:6f:24:a5:e4:c1:1c:00:8d:fb:3b [email protected]

The key's randomart image is:

+--[ RSA 2048]----+

| .+... |

| . .o . |

| . = . |

| .. = + |

| .o S . |

| ..+ B |

| o.= o |

| E. o |

| . |

+-----------------+

       b、 Save the key pair to authorkeys_keys in

[email protected]:~/.ssh# cat id_rsa.pub >> authorized_keys

    c、 Set up authorized_keys jurisdiction :

# chmod 600 authorized_keys

d、 modify /etc/ssh/sshd_config In file :

1.RSAAuthentication yes #  Enable RSA  authentication

2.PubkeyAuthentication yes #  Enable public key private key pairing authentication mode

3.AuthorizedKeysFile ~/.ssh/authorized_keys #  Public key file path

e、[email protected]:#ssh localhost Verify that you can enter the local without a password

2、 To configure hadoopnamenode Login without password hadoopdatanode1 and hadoopdatanode2( Now hadoopdatanode1 For example )

a、 take namenode Copy the public key on to datanode On the machine :

#scp ~/.ssh/authorized_keys [email protected]:~/.ssh/

This command still needs to enter the password , This is normal .

b、 land hadoopdatanode1, take ssh Directory permission modification , namely ~/.ssh

chmod 700 ~/.ssh

c、 hold hadoopdatanode1 Of ssh In the catalog id_rsa.pub The content of is added to authorized_keys in

#cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys

d、 hold hadoopdatanode1 Medium id_rsa.pub Delete the

#rm ~/.ssh/id_rsa.pub

e、 Can be in hadoopnamenode Log on hadoopdatanode1

[email protected]:#ssh hadoopdatanode1

3、 Guarantee hadoopdatanode1 Or is it hadoopdatanode2 Login without password hadoopnamenode( With hadoopdatanode1 For example )

a、hadoopdatanode1 The public key of is appended to hadoopnamenode On

#ssh-keygen -t dsa

#cat ~/.ssh/id_dsa.pub authorized_keys

b、hadoopdatanode1 Upper id_dsa.pub Copied to the hadoopnamenode Of ssh Under the table of contents , And add the content to authorized_keys in

#scp ~/.ssh/id_dsa.pub [email protected]:~/.ssh/

#cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keysc、 verification hadoopdatanode1 Can I log in without password hadoopnamenode

[email protected]:#ssh hadoopnamenode

Do you feel particularly irritable through the above operations ! In fact, the summary is just one sentence , stay authorized Must have hadoopnamenode Of id_rsa.pub And the secret key to hadoopdatanode Of id_dsa.pub The secret key to , That is to say namenode The public key and datanode The secret key of authorized_keys Let the cluster ssh Login without password , Whether it's master And slaver still slaver And slaver Between , It's all right . This is the result of my research , I hope it will help you all .

原网站

版权声明
本文为[se7en_ q]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/180/202206290319133354.html