• ssh key公钥


    在ubuntu上生成ssh key

    首先使用

    ls -al ~/.ssh

    查看本地是否已经有key

    如果没有会显示如下:

    ~$ ls -al ~/.ssh
    ls: cannot access '/home/liuxueneng/.ssh': No such file or directory

    使用ssh-keygen 生成新的key

    提示 

    Enter file in which to save the key (/home/liuxueneng/.ssh/id_rsa):

    的时候直接回车按照默认名字就可以

    提示

    Enter passphrase (empty for no passphrase):
    的时候最好输入passphrase并记住后面会用的到



    liuxueneng@airfly-dev:~$ ssh-keygen  -t rsa -C "liuxueneng@iairfly.com"
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/liuxueneng/.ssh/id_rsa): 
    Created directory '/home/liuxueneng/.ssh'.
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /home/liuxueneng/.ssh/id_rsa.
    Your public key has been saved in /home/liuxueneng/.ssh/id_rsa.pub.
    The key fingerprint is:
    SHA256:aXmIOOJDa+H1Urcz6KAJBvg1Zu97S0OpDhAu1beseXQ liuxueneng@iairfly.com
    The key's randomart image is:
    +---[RSA 2048]----+
    |                 |
    |   .             |
    |  o . .          |
    |.o . + o =       |
    |+ * O * E .      |
    |.* X X B o       |
    |..B * * *        |
    |.o + O ..+       |
    |  o   =o..       |
    +----[SHA256]-----+

    再次查看生成的key,可以看到id_rsa和 id_rsa.pub两个文件

    ls -al ~/.ssh/
    total 16
    drwx------  2 liuxueneng liuxueneng 4096 Apr 24 13:53 .
    drwx------ 15 liuxueneng liuxueneng 4096 Apr 24 13:55 ..
    -rw-------  1 liuxueneng liuxueneng 1766 Apr 24 13:53 id_rsa
    -rw-r--r--  1 liuxueneng liuxueneng  404 Apr 24 13:53 id_rsa.pub

    接下来ssh-add 

    如果出现提示“Could not open a connection to your authentication agent.”

    则执行ssh-agent bash启动agent

    再次ssh-add就可以了

     ssh-add ~/.ssh/id_rsa
    Could not open a connection to your authentication agent.
    liuxueneng@airfly-dev:~$ ssh-agent bash
    liuxueneng@airfly-dev:~$ ssh-add ~/.ssh/id_rsa
    Enter passphrase for /home/liuxueneng/.ssh/id_rsa: 
    Identity added: /home/liuxueneng/.ssh/id_rsa (/home/liuxueneng/.ssh/id_rsa)

    提示

    Enter passphrase
    的时候输入第一次设置的passphrase即可
  • 相关阅读:
    WebService帮助类改良版,支持多webservice
    .NET-list扩展方法Distinct去重
    C#创建泛型类T的实例的三种方法
    划水网站
    DataGridView增加右键取消操作
    Sql Server 快捷键
    SQL Server中使用convert进行日期转换
    ToolStrip 选中某一项打勾
    H5实现手写功能
    git使用
  • 原文地址:https://www.cnblogs.com/tid-think/p/10762124.html
Copyright © 2020-2023  润新知