• 使用ssh-keygen生成私钥和公钥


    1.使用ssh-keygen生成私钥和公钥

    命令如下:

    ssh-keygen -t rsa
    ssh-keygen -t rsa -C "用户名自取"
    可以是邮箱

    例子:

    fdipzone@ubuntu:~$ ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/fdipzone/.ssh/id_rsa): 这里输入要生成的文件名
    Enter passphrase (empty for no passphrase):                       这里输入密码 
    Enter same passphrase again:                                      这里重复输入密码
    Your identification has been saved in /home/fdipzone/.ssh/id_rsa.
    Your public key has been saved in /home/fdipzone/.ssh/id_rsa.pub.
    The key fingerprint is:
    f2:76:c3:6b:26:10:14:fc:43:e0:0c:4d:51:c9:a2:b0 fdipzone@ubuntu
    The key's randomart image is:
    +--[ RSA 2048]----+
    |    .+=*..       |
    |  .  += +        |
    |   o oo+         |
    |  E . . o        |
    |      ..S.       |
    |      .o .       |
    |       .o +      |
    |       ...oo     |
    |         +.      |
    +-----------------+

    参数 -t rsa 表示使用rsa算法进行加密,执行后,会在/home/当前用户/.ssh目录下找到id_rsa(私钥)和id_rsa.pub(公钥)

    fdipzone@ubuntu:~$ ls -lt ~/.ssh
    总用量 12
    -rw------- 1 fdipzone fdipzone 1679 2015-08-07 00:28 id_rsa
    -rw-r--r-- 1 fdipzone fdipzone  397 2015-08-07 00:28 id_rsa.pub

    也可以使用 dsa 加密算法进行加密,命令如下:

    ssh-keygen -t dsa

    2.设定客户端连接使用的ssh私钥和公钥

    vim /etc/ssh/ssh_config

    找到

    #   IdentityFile ~/.ssh/identity
    #   IdentityFile ~/.ssh/id_rsa
    #   IdentityFile ~/.ssh/id_dsa

    把前面#去掉,然后在 IdentityFile 后填写你用来执行ssh时所用的密钥

  • 相关阅读:
    GDI+ 实现透明水印和文字
    delphi调用LUA函数来处理一些逻辑
    Delphi 不使用自带模板创建服务
    Delphi在Listview中加入Edit控件
    中文转码器的工作原理_delphi教程
    使用钩子函数[6]
    简单全局HOOK拦截大部分键盘消息
    4个字节就相当于移动一位,原来指针是这样用的
    C#调用Delphi接口(ITest = interface)
    DELPHI 对象的本质 VMT
  • 原文地址:https://www.cnblogs.com/tiancai/p/11685468.html
Copyright © 2020-2023  润新知