zoukankan      html  css  js  c++  java
  • 3步实现ssh面密码登录

    1、上次本机的公钥和私钥

    [root@vicweb ~]#ssh-keygen -t rsa
    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:
    24:ef:78:23:bf:51:2f:40:8b:b8:c8:f6:87:34:69:a4 root@vicweb.localdomain
    The key's randomart image is:
    +--[ RSA 2048]----+
    |                 |
    |                 |
    |      . o        |
    |    .. * .       |
    |   o... S .      |
    | .E.=. o o .     |
    |  +o.oo = . .    |
    | . .. .+ o .     |
    |    ..  o.       |
    +-----------------+

    2、查看生产的文件(非必要操作,只是确认一下)

    3、把公钥传输到指定机器,需要免密码ssh登录的机器,使用ssh-copy-id命令

    [root@vicweb ~]#ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.10.90.102
    The authenticity of host '10.10.90.102 (10.10.90.102)' can't be established.
    RSA key fingerprint is 05:90:7f:36:f2:c4:55:15:16:2d:27:54:30:67:c7:74.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '10.10.90.102' (RSA) to the list of known hosts.
    root@10.10.90.102's password: 
    Now try logging into the machine, with "ssh 'root@10.10.90.102'", and check in:
    
      .ssh/authorized_keys
    
    to make sure we haven't added extra keys that you weren't expecting.

    check in到了对方的 authorized_keys文件,对方机器默认是没有这个文件的,会自动生产一个这个文件,并把自己的公钥写到这个文件

    4、测试登录即可

    [root@vicweb ~/.ssh]#ssh root@10.10.90.102
    Last login: Thu Nov  9 09:24:35 2017 from 10.10.90.1

    已实现自动登录,不需要在输入对方root的密码。

  • 相关阅读:
    mysql的root用户无法建库的问题
    jmeter连库获取sql结果存为参数给下一接口用
    webservice接口问题
    今日杂记-20190623
    接口测试
    pyenv和virtualenv管理python的版本(多个版本同时用)
    安装禅道
    经典题,类中的变量
    CSS简介
    python单元测试unittest
  • 原文地址:https://www.cnblogs.com/netsa/p/7807890.html
Copyright © 2011-2022 走看看