zoukankan      html  css  js  c++  java
  • 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]#
  • 相关阅读:
    windows server2012之部署HTTPS安全站点
    HTTPS站点搭建教程:Win7/Windows Server 2008R2
    https,https的本地测试环境搭建,asp.net结合https的代码实现,http网站转换成https网站之后遇到的问题
    SQL Server中解决死锁的新方法介绍
    WCF寄宿到Windows Service[1]
    安装程序工具 (Installutil.exe)22
    安装程序工具 (Installutil.exe)
    WebSocket使用教程
    深入理解java String 对象的不可变性
    Android 给Button加个监听
  • 原文地址:https://www.cnblogs.com/likezn/p/10767299.html
Copyright © 2011-2022 走看看