Linux配置SSH免登陆

前言:

     本文主要是我在安装hadoop集群之前,配置SSH免登陆。在网上搜索结合自己实际操作之后的一些总结,记录在此,作为参考。

 

正文:

1、修改sshd的配置文件(需要root权限),执行如下命令: 

  打开sshd

[root@hadoop1-1 hadoop]#  vim /etc/ssh/sshd_config

  将#StrictModes yes改成StrictModes no

     

  注:此步操作为了避免重启后失效

  重启网络服务

[root@hadoop1-1 hadoop]# service network restart

 

2、设置SSH免登陆

  #生成ssh免登陆密钥(执行命令时直接敲四个回车)

ssh-keygen -t rsa 

  执行完这个命令后,在用户目录的.ssh文件夹下会生成两个文件id_rsa(私钥)、id_rsa.pub(公钥)

  #添加免登陆主机

  根据提示先输入“yes”,然后输入目标主机的密码,显示如下信息表示添加完成。

[hadoop@hadoop1-1 ~]$ ssh-copy-id hadoop1-8
The authenticity of host 'hadoop1-8 (192.168.2.170)' can't be established.
RSA key fingerprint is cc:4e:23:01:ca:97:52:21:85:78:bc:29:ca:b3:12:52.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'hadoop1-8' (RSA) to the list of known hosts.
hadoop@hadoop1-8's password: 
Now try logging into the machine, with "ssh 'hadoop1-8'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

  

3、测试登录

[hadoop@hadoop1-1 ~]$ ssh hadoop1-8
Last login: Sun Mar 26 05:24:08 2017 from 192.168.2.2
[hadoop@hadoop1-8 ~]$ 

  正常情况下,不会提示输入密码,直接跳转至目标主机,表示配制成功!!!

posted @ 2017-03-26 22:30  skyfeng713  阅读(447)  评论(0编辑  收藏  举报