美文网首页
github配置密钥SSH keys

github配置密钥SSH keys

作者: Jannonx | 来源:发表于2017-10-10 11:04 被阅读21次

    当你github创建了一个仓库后,关联本地文件,可能出现以下情况:

    • 初始化
    $ git commit -m "init page"
    [master (root-commit) d832761] init page
     1 file changed, 7 insertions(+)
     create mode 100644 index.html
    
    • 关联本地文件
    $ git remote add origin git@github.com:xxxxx/xxxxx.github.io.git
    
    • remote远程
    $ git push -u origin master
    Permission denied (publickey).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    
    • 这是因为本机没有给github配置密匙
    $ ssh-keygen -t rsa -C 你的邮箱地址
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
    Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
    The key fingerprint is:
    2c:03:89:09:5c:4c:2a:b9:2b:bd:ec:2b:a0:ce:ff:22 791273579@qq.com
    The key's randomart image is:
    +--[ RSA 2048]----+
    |o +o             |
    | +.+ .           |
    |o.o o            |
    |..   . .         |
    |.     o S        |
    |.o     o         |
    |= .              |
    |=E o             |
    |.=Boo.           |
    +-----------------+
    
    • 根据路径找到id_rsa.pub文件,复制里面的内容,粘贴到github的personal settings的SSH keys中

      QQ截图20171010110138.png
    • 再一次push, 输入密码,done

    $ git push -u origin master
    Enter passphrase for key '/c/Users/Administrator/.ssh/id_rsa':
    Counting objects: 3, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 293 bytes | 0 bytes/s, done.
    Total 3 (delta 0), reused 0 (delta 0)
    To git@github.com:xxxxx/xxxxx.github.io.git
     * [new branch]      master -> master
    Branch master set up to track remote branch master from origin.
    

    相关文章

      网友评论

          本文标题:github配置密钥SSH keys

          本文链接:https://www.haomeiwen.com/subject/ahhvyxtx.html