linux ssh免密登入配置

免密登入配置

[hadoop@Hadoop001 ~]$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hadoop/.ssh/id_rsa): 
Created directory '/home/hadoop/.ssh'.
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:
24:75:46:0a:ca:00:01:5c:a3:0a:73:06:89:b5:96:f8 hadoop@Hadoop001
The key's randomart image is:
+--[ RSA 2048]----+
|O=+o  . ..+      |
|o+.=.. o +       |
|+.* o . o        |
|o*     o         |
|. E     S        |
|                 |
|                 |
|                 |
|                 |
+-----------------+
[hadoop@Hadoop001 .ssh]$ cat id_rsa.pub >> authorized_keys
[hadoop@Hadoop001 .ssh]$ ll
total 12
-rw-rw-r-- 1 hadoop hadoop  398 Jul  1 09:10 authorized_keys
-rw------- 1 hadoop hadoop 1675 Jul  1 09:09 id_rsa
-rw-r--r-- 1 hadoop hadoop  398 Jul  1 09:09 id_rsa.pub
必须要修改authorized_keys文件权限
[root@Hadoop001 .ssh]# chmod 600 authorized_keys
加date可以直接返回结果,而不做机器切换
[hadoop@Hadoop001 .ssh]$ ssh localhost date
The authenticity of host 'localhost (::1)' can't be established.
RSA key fingerprint is db:f0:34:e6:e1:90:a5:84:25:18:99:2e:00:cb:e5:88.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
Mon Jul  1 09:13:05 CST 2019

如果以后有多台机器只需要把每台机器生成的公钥内容添加到这个authorized_keys文件中,然后在把个文件分发到其他的机器即可。

你可能感兴趣的:(linux ssh免密登入配置)