• SSH免密登录


    ssh免密登录

    1.切入/root/.ssh路径下,使用 ssh-keygen获取主机key。
    注:直接回车即可,无需输入任何信息。
    [root@likeadmin ~/.ssh]#  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:
    SHA256:wHcQJ9gL4yUdpYnxOnMU3HRigDkL5hT4C5itp1E0eAA root@likeadmin
    The key's randomart image is:
    +---[RSA 2048]----+
    |Eo ....BBB* .    |
    |. = +.O+=O.o     |
    | * * o+B*..      |
    |o + o o=..       |
    | o . .+ S        |
    |o . .  +         |
    | +               |
    |.                |
    |                 |
    +----[SHA256]-----+
    [root@likeadmin ~/.ssh]#
     
    2.检查生成的key文件
    [root@likeadmin ~/.ssh]# ls -l
    total 12
    -rw-------. 1 root root 1675 Apr  3 16:47 id_rsa
    -rw-r--r--. 1 root root  396 Apr  3 16:47 id_rsa.pub
    -rw-r--r--. 1 root root  177 Apr  3 16:41 known_hosts
    [root@likeadmin ~/.ssh]#
     
    3.使用ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.164.129生成到目标主机key。
    注:192.168.164.129为目标主机IP。
    [root@likeadmin ~/.ssh]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.164.129
    /bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
    /bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
    /bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
    root@192.168.164.129's password:    注:此次输入目标主机root密码。
     
    Number of key(s) added: 1
     
    Now try logging into the machine, with:   "ssh 'root@192.168.164.129'"
    and check to make sure that only the key(s) you wanted were added.
     
    [root@likeadmin ~/.ssh]#
     
    4.测试到ssh免密到目标主机
    [root@likeadmin ~/.ssh]# ssh 192.168.164.129
    Last login: Tue Apr  2 16:21:12 2019
    [root@likenode ~]#
    [root@likenode ~]# hostname
    likenode
    [root@likenode ~]# exit
    [root@likeadmin ~/.ssh]#
     
  • 相关阅读:
    servlet规范核心类图
    策略模式
    掌握Spark机器学习库-07-回归算法原理
    掌握Spark机器学习库-07-线性回归算法概述
    掌握Spark机器学习库-07-回归分析概述
    掌握Spark机器学习库-06-基础统计部分
    掌握Spark机器学习库-05-spark中矩阵与向量的使用
    测试开发要懂的设计模式知识
    数据可视化工具-ECharts
    掌握Spark机器学习库-02-mllib数据格式
  • 原文地址:https://www.cnblogs.com/hardy46/p/12897948.html
Copyright © 2020-2023  润新知