zoukankan      html  css  js  c++  java
  • 创建SSH密钥

    Step1: 检查SSH密钥

    首先,打开终端,输入以下指令,查看是否已经生成SSH密钥。

    cd ~/.ssh
    ls
    # Lists the files in your .ssh directory

    在输入ls后,看看是否有文件 id_rsa.pub 或者 id_dsa.pub,或者两者皆有。如果已经存在这两个文件,则不需进行Step 2,之前如果输入了密码,可以直接跳过Step3。

    Step2: 生成新的SSH密钥

    输入下面的第一条指令,指令中输入一个邮箱,会出现要你自己定义一个文件来保存Key,直接Enter通过。

    ssh-keygen -t rsa -C "your_email@example.com"
    # Creates a new ssh key, using the provided email as a label
    # Generating public/private rsa key pair.
    # Enter file in which to save the key (/home/you/.ssh/id_rsa):

    输入密码(不能少于4个,否则重输入)。

    # Enter passphrase (empty for no passphrase): [Type a passphrase]
    # Enter same passphrase again: [Type passphrase again]

    终端给出的信息如下,告诉Key的保存位置,后面需要用到。

    # Your identification has been saved in /home/you/.ssh/id_rsa.
    # Your public key has been saved in /home/you/.ssh/id_rsa.pub.
    # The key fingerprint is:
    # 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com

    Step3: 添加SSH Key到GitHub

    运行下面这些指令:(打了#号的不用,)。

    sudo apt-get install xclip
    # Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)
     
    xclip -sel clip < ~/.ssh/id_rsa.pub
    # Copies the contents of the id_rsa.pub file to your clipboard

     

    进入网站GitHub,对以下进行设置:

    1.      点击账户设置(很明显的,就在右上角);

    2.      点击 "SSHKeys" 在左边;

    3.      工作区出现

    点击Add SSH key,出现下面。

    4.      点击 "Add key"

    5.      输入密码进行确认,这个密码就是在Step 3中输入的密码,这个弹出窗口会在输入

    xclip -sel clip < ~/.ssh/id_rsa.pub

    指令是出现。

    Step4: 测试是否成功

    ssh -T git@github.com
    # Attempts to ssh to github

    输入上面的指令,而且指令中的git@github.com是不可以随意输的,一般就是这个,其实也就是这个。

    可能出现的错误信息:

    ...
    Agent admitted failure to sign using the key.
    debug1: No more authentication methods to try.
    Permission denied (publickey).

    警告:

    # The authenticity of host 'github.com (207.97.227.239)' 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,直接秒杀。

    # Hi username! You've successfully authenticated, but GitHub does not
    # provide shell access.

    成功的是:

    If that username is correct, you've successfully set up your SSH key. Don't worry about the shell access thing, you don't want that anyway.
  • 相关阅读:
    BZOJ 2069 POI2004 ZAW 堆优化Dijkstra
    浏览器大小屏适配的方法
    编译性语言&amp;解释性语言
    ubuntu 查看网卡 数据包处理 速度
    使用Newtonsoft JsonConvert反序列化Json数据到DataTable
    easyUI datagrid view扩展
    easyUI layout 中使用tabs+iframe解决请求两次方法
    oracle自定义判断数据是否为数值函数
    easyUI datagrid editor扩展dialog
    JavaScript格式化日期
  • 原文地址:https://www.cnblogs.com/kaola8023/p/7640696.html
Copyright © 2011-2022 走看看