zoukankan      html  css  js  c++  java
  • ssh秘钥

    啦啦啦,一个任务来了,在阿里云上申请了一台服务器,想当然的就用户名密码交付给了研发,研发说,要用秘钥呀,难道是我孤陋寡闻了,哈哈哈!!

    在Linux上搞ssh秘钥

    1、root用户登陆后,运行以下第一句指令,其他根据提示进行输入:

    ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa):                 建议直接回车使用默认路径
    Created directory '/root/.ssh'
    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:
    05:71:53:92:96:ba:53:20:55:15:7e:5d:59:85:32:e4 root@test
    The key's randomart image is:
    +--[ RSA 2048]----+
    |   o o ..                |
    | . o oo.+ .            |
    | o.+... =               |
    | ...o                     |
    | o S                     |
    | .                         |
    |                           |
    |                           |
    |                           |
    +--------------------+

    此时在/root/.ssh/目录下生成了2个文件,id_rsa为私钥,id_rsa.pub为公钥。私钥自己下载到本地电脑妥善保存(丢了服务器可就没法再登陆了),为安全,建议删除服务器端的私钥。公钥则可以任意公开。

    2、使用以下命令将公钥导入到VPS:

    cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

    3、修改SSH的配置文件/etc/ssh/sshd_config :

    #RSAAuthentication yes
    #PubkeyAuthentication yes
    #AuthorizedKeysFile .ssh/authorized_keys

    去调上面3行前面的#,保存后重启SSH服务。

    service sshd restart

    然后再把研发给的pub后缀的文件里的内容,添加到authorized_keys 文件即可

  • 相关阅读:
    kinect 2(ubuntu16.04)
    编译、执行错误合辑
    Qt5学习笔记(基础)
    内核格式化(C++)
    (3)视觉里程计 Visual Odometry
    字符串搜索 find()
    (2)特征点匹配,并求旋转矩阵R和位移向量t
    27. Remove Element
    快看漫画面试经历
    面试题40:最小的 k 个数
  • 原文地址:https://www.cnblogs.com/lazyball/p/7404141.html
Copyright © 2011-2022 走看看