centos6 ssh-keygen 免密码 自动登陆

分类: LINUX

环境: centos6a,centos6b,centos6c
需求:从centos6a免密码,自动登陆到centos6b或者centos6c
步骤:

1 修改每台机器的/etc/hosts文件,内容如下
127.0.0.1 localhost
192.168.0.2 centos6a
192.168.0.3 centos6b
192.168.0.4 centos6c

2 本机创建ssh密钥 

centos6a#:  ssh-keygen -t rsa -'' -f ~/.ssh/id_dsa
-P表示密码,-P '' 就表示空密码,也可以不用-P参数,这样就要三车回车,用-P就一次回车。

3  拷贝密钥到“被登陆机”输入密码,

centos6a#:~/.ssh#scp id_rsa.pub centos6b:~/.ssh/
centos6a#:~/.ssh#scp id_rsa.pub centos6c:~/.ssh/  

4 ssh到“被登陆机”(centos6b,centos6c)把密钥改成 “authorized_keys”

           centos6b#:~/.ssh# mv id_rsa.pub authorized_keys
           centos6c#:~/.ssh# mv id_rsa.pub authorized_keys

5  在“被登陆机”(centos6b,centos6c)上执行命令 restorecon 
说明:There is a bug in CentOS 6 / SELinux that results in all client presented certificates to be ignored when SELinux is set to Enforcing. To fix this simply: 

      centos6b#:restorecon -R -v ~/.ssh
     centos6c#:restorecon -R -v ~/.ssh
或者 

     centos6b#: setenforce 0
     centos6c#: setenforce 0

6 ssh centos6b 这样就实现无密码登陆

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值