• sshkey验证github


    使用ssh key验证github的好处就是不用每次提交代码的时候都要输入用户名和密码,因为着在一定程度上对效率有很大的影响,虽然这么做可以防止代码提交的次数过多,但这也看个人的习惯吧。

    今天尝试了一下配置ssh key

    OS:mac os

    打开控制台,建一个目录,比如~/.ssh(其实叫什么都无所谓,网上搜的基本上都这么配置)

    在该目录下输入命令:

    ssh-keygen -t rsa -C "youname@example.com"

    注意:双引号换成自己的邮箱,如果遇到权限问题,只需在前面加上sudo

    复制代码
    Generating public/private rsa key pair.
    Enter file in which to save the key (/var/root/.ssh/id_rsa): ./id_rsa#这里填的是保存文件的路径
    Enter passphrase (empty for no passphrase):#直接enter跳过 
    Enter same passphrase again: #同上
    Your identification has been saved in ./id_rsa.
    Your public key has been saved in ./id_rsa.pub.
    The key fingerprint is:
    25:68:54:4a:f1:03:ab:78:15:3f:f7:9d:f0:bf:08:ee bsn.huang@gmail.com
    The key's randomart image is:
    +--[ RSA 2048]----+
    |      *o.        |
    |     o O         |
    |      * * o .    |
    |   . +   * . + . |
    |  . o   S   . +  |
    |   .           . |
    |           .    .|
    |          . . . .|
    |          .E . . |
    +-----------------+
    复制代码

    这个时候,在.ssh目录下有两个文件

    id_rsa        id_rsa.pub

    其中id_rsa是私钥 id_rsa.pub是公钥

    然后,执行下面的命令,将生成的key添加

    ssh-add id_rsa

    然后将id_rsa.pub里面的内容复制下来,在github上的settings里面找到add keys,将其粘贴到key即可,title随便填

    这个时候可以在控制台上测试一下

    复制代码
    $ ssh -T git@github.com
    The authenticity of host 'github.com (192.30.252.128)' can't be established.
    RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
    Are you sure you want to continue connecting (yes/no)? yes
    Failed to add the host to the list of known hosts (/Users/Bsn/.ssh/known_hosts).
    Hi bsnwong! You've successfully authenticated, but GitHub does not provide shell access.
    复制代码

    其他不用管,只要看到最后一行,说明验证成功了

    后话:刚开始忘记执行ssh-add id_rsa 命令,一直验证不成功,困在这里好久

  • 相关阅读:
    js上传文件(图片)限制格式及大小为3M
    position:fixed部分版本的浏览器不支持
    iframe自适应高度的方法
    div左右自适应高度一致
    IE中部分版本的浏览器对Select标签设置innerHTML无效的问题
    在ie10中如何禁用输入框中的小眼睛 与 叉叉 删除按钮
    input输入框默认文字,点击消失
    调用iframe中父页面/子页面中的JavaScript方法
    iframe的一些介绍
    artDialog的一些例子与一些属性的介绍。
  • 原文地址:https://www.cnblogs.com/visuals/p/5237661.html
Copyright © 2020-2023  润新知