zoukankan      html  css  js  c++  java
  • ssh免密码登陆

    Ssh免密码登陆设置

    准备工作:1.确保两个主机里没有id_rsa.pubauthorized_keys的文件(这两个文件会影响实验的结果)# find / -name id_rsa.pub可查看是否有这个文件。

    2.两个主机已安装ssh # rpm -qa |grep openssh 可查看是否安装ssh的相关包

    说明:A(192.168.1.106B192.168.1.11

    一、A主机执行ssh-keygen

    [root@A ~]# ssh-keygen

    Generating public/private rsa key pair.

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

    Created directory '/root/.ssh'.

    Enter passphrase (empty for no passphrase):

    Enter same passphrase again:

    Your identification has been saved in /root/.ssh/id_rsa.

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

    The key fingerprint is:

    75:06:e4:cb:25:67:5e:32:fb:9e:28:0a:24:09:18:aa root@lxh

    The key's randomart image is:

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

    |.        .o      |

    |.o       . .     |

    |o .       + O .  |

    |.  . .   o X =   |

    |E   o . S o o    |

    |     o       .   |

    |      .       .  |

    |       .  .  o . |

    |        .. .. o  |

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

    二、在B主机建立文件夹

    [root@B~]# mkdir /root/.ssh

    三、在A主机传送文件

    [root@A ~]# scp /root/.ssh/id_rsa.pub root@192.168.1.111:/root/.ssh/authorized_keys

    root@192.168.1.111's password:

    id_rsa.pub 

    四、在A主机连接B主机

    [root@A ~]# ssh root@192.168.1.111

    Last login: Sun Mar 13 22:31:50 2016 from 192.168.1.106

    [root@B ~]#

    这样就不用输入密码成功连接到B主机了,输入exit退出B主机返回A主机。

    [root@A ~]# ssh 192.168.1.111 ls

    anaconda-ks.cfg

    install.log

    install.log.syslog

    这样可以直接用B主机执行命令在A主机显示。

  • 相关阅读:
    ASP.NET AJAX Beta 1 发布 (转载)
    ASP.NET里常用的JS (转贴)
    让您的Ajax应用加载数据时界面友好 (转贴)
    模态窗口 javascript html
    最亲密接触Dhtml&JScript开发细节 (转贴)
    Hashtable的使用
    2009年全国年节及纪念日放假办法
    详解.NET中的动态编译
    CSS2.0样式手册_说明_SDK下载chm
    [转]DISTINCT 和 ORDER BY 使用第三个字段进行排序
  • 原文地址:https://www.cnblogs.com/rohero/p/5274076.html
Copyright © 2011-2022 走看看