zoukankan      html  css  js  c++  java
  • 从主机A得到id_rsa.pub文件,在主机B创建用户danny加入该文件,实现主机A免密登录主机B

    操作步骤:

    1.主机A

    生成公钥id_rsa.pub文件并导出该文件

    root@mytest:~# ssh-keygen 
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa): 
    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:
    7e:0f:dc:05:2e:d3:e0:24:c0:5f:fe:cf:e9:7a:f7:49 root@mytest
    The key's randomart image is:
    +--[ RSA 2048]----+
    |     ..          |
    |      ..  .      |
    |       ..oo .    |
    |        .+.+ .   |
    |        S +.o .  |
    |       . . +..   |
    |        . + .o E |
    |         . o  * o|
    |            o+.oo|
    +-----------------+
    root@mytest:~# sz /root/.ssh/id_rsa.pub 

    这步之后也可以通过以下步骤直接实现公钥认证(但是需要知道主机B用户danny的密码)

    # ssh-copy-id -i /root/.ssh/id_rsa.pub danny@12.1.1.2
    danny@12.1.1.2's password:      //输入主机B用户danny的登录密码

    2.主机B

    得到id_rsa.pub文件,创建用户danny,并在该用户家目录创建.ssh文件夹和其文件下的远程认证文件authorized_keys

    [root@B danny]# mkdir .ssh
    [root@B danny]# cd .ssh/
    [root@B .ssh]# touch authorized_keys
    [root@B .ssh]# ls
    authorized_keys
    [root@B .ssh]# cat /home/danny/id_rsa.pub >authorized_keys

    主机A登录主机B

    root@mytest:/# ssh danny@IP_B
  • 相关阅读:
    网站首页蒙灰CSS样式
    MATLAB数值计算编程题
    通过P/Invoke控制继电器
    Java实习生入职测试
    navicat for mongodb12破解
    用svg绘制圣诞帽
    Excel条件格式
    10道算法题
    从事软件开发工作10年后的总结
    ASP.NET Core MVC+EF Core从开发到部署
  • 原文地址:https://www.cnblogs.com/dannylinux/p/9567300.html
Copyright © 2011-2022 走看看