Luoml's blog

git ssh-keygen

  • 查看帮助
    git help

  • 查看状态
    git status

  • 查看配置
    git conifg -l

  • 增加配置项
    git config [--local|--global|--system] -add section.key value

  • 删除配置项
    git config [--local|--global|--system] --unset section.key

  • 检查是否已有SSH Key
    cd ~/.ssh

  • 生成ssh密钥
    ssh-keygen -t rsa -C "ml_luo@126.com"

  • 删除ssh密钥
    $ ssh-add -D

  • 异常:Could not open a connection to your authentication agent.
    解决办法:
    $ eval $(ssh-agent -s)

  • 增加ssh密钥
    $ ssh-add ~/.ssh/id_rsa_github

    1
    Identity added: /c/Users/Administrator/.ssh/id_rsa_github (/c/Users/Administrator/.ssh/id_rsa_github)
  • 查看ssh密钥
    $ ssh-add -l

    1
    2048 SHA256:YfZfL+vo4ADQ8n4v7at5ICzNOTX8MyqDW0tPn/5X3fQ /c/Users/Administrator/.ssh/id_rsa_github (RSA)
  • 异常:Permission denied (publickey).
    解决办法:
    将ssh密钥拷贝到github/coding等,并在~/.ssh/增加文件config,文件内容如下:

    1
    2
    3
    4
    Host github.com
    IdentityFile ~/.ssh/id_rsa_github
    Host git.coding.net
    IdentityFile ~/.ssh/id_rsa_github
  • 异常: The authenticity of host '... ...' can't be established
    解决办法:
    $ ssh -vt git@git.coding.net

    1
    2
    3
    4
    5
    ...
    The authenticity of host 'git.coding.net (61.179.108.67)' can't be established.
    RSA key fingerprint is SHA256:jok3FH7q5LJ6qvE7iPNehBgXRw51ErE77S0Dn+Vg/Ik.
    Are you sure you want to continue connecting (yes/no)? yes
    ...
  • 验证github
    $ ssh -T git@github.com

    1
    Hi luoml! You've successfully authenticated, but GitHub does not provide shell access.
  • 验证coding.net
    $ ssh -T git@git.coding.net

    1
    Hello luoml! You've connected to Coding.net via SSH successfully!
Fork me on GitHub