• 使用ssh-keygen生成密钥对


    命令:

    ssh-keygen -t rsa -f ~/.ssh/id_rsa -N shoufeng -C shoufeng

    ssh-keygen常用参数说明:

    -t: 密钥类型, 可以选择 dsa | ecdsa | ed25519 | rsa; 省略的情况下默认是rsa
    
    -f: 密钥目录位置,指定生成密钥的保存路径和文件名。省略的情况下, 默认为当前用户home路径下的.ssh隐藏目录, 也就是~/.ssh/, 同时默认密钥文件名以id_rsa开头.
      -f省略的情况下,默认目录就是~/.ssh/,不会再次提醒输入。但是会再次提是你输入文件名,如果不输入直接回车,则默认的密钥文件名就是id_rsa
    -C: 指定此密钥的备注信息, 需要配置多个免密登录时, 建议携带;生成的公钥会在最后面显示此备注信息
    
    -N: 指定此密钥对的密码, 如果指定此参数, 则命令执行过程中就不会出现交互确认密码的信息了.如果省略此参数,会提示你输入密码和密码确认。一般情况下不用输入,直接回车就行。
      如果输入密码之后,以后每次都要输入密码。这里请根据你的安全需要决定是否需要密码,如果不需要,直接回车:

    一般情况下,简单的执行ssh-keygen,并按回车就可以生成密钥对了

    ssh-keygen

    这时就会在 ~/.ssh目录下生成两个文件id_rsa和id_rsa.pub,前者为私钥,后者为公钥

    实例

    [vagrant@localhost .ssh]$ cd ~
    [vagrant@localhost ~]$ cd .ssh
    [vagrant@localhost .ssh]$ ll
    total 4
    -rw-------. 1 vagrant vagrant 389 Sep 12 06:01 authorized_keys
    [vagrant@localhost .ssh]$ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/vagrant/.ssh/id_rsa): 
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /home/vagrant/.ssh/id_rsa.
    Your public key has been saved in /home/vagrant/.ssh/id_rsa.pub.
    The key fingerprint is:
    SHA256:DI6VWWlGpw5g76EB/rYBxVz9nHqwcwKLM6bDAwXNc94 vagrant@localhost.localdomain
    The key's randomart image is:
    +---[RSA 2048]----+
    | o.o+..oo..      |
    |..+++o +=o       |
    | .o+..Oo.o .     |
    |  .o.BE*. +      |
    | .  *.ooS+       |
    |.  .=o. = o      |
    | o o.o   =       |
    |  =              |
    |   o             |
    +----[SHA256]-----+
    [vagrant@localhost .ssh]$ ll
    total 12
    -rw-------. 1 vagrant vagrant  389 Sep 12 06:01 authorized_keys
    -rw-------  1 vagrant vagrant 1675 Oct  3 07:52 id_rsa
    -rw-r--r--  1 vagrant vagrant  411 Oct  3 07:52 id_rsa.pub
    [vagrant@localhost .ssh]$ 
  • 相关阅读:
    Android Push Notification实现信息推送使用
    线段树 Interval Tree
    树状数组
    LCA和RMQ
    RMQ (Range Minimal Query) 问题 ,稀疏表 ST
    winner tree 胜者树
    ORA-64379: Action cannot be performed on the tablespace assigned to FastStart while the feature is enabled
    mybatis 查询优化主子表查询之association和collection
    Oracle 11gR2 用户重命名(rename user)
    redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: 断开的管道 (Write failed)
  • 原文地址:https://www.cnblogs.com/gaoBlog/p/11619917.html
Copyright © 2020-2023  润新知