查看版本

$ ssh -V
OpenSSH_7.6p1, OpenSSL 1.0.2n 7 Dec 2017

http://superuser.com/questions/232373/how-to-tell-git-which-private-key-to-use

In ~/.ssh/config, add:

host github.com
HostName github.com
IdentityFile ~/.ssh/id_rsa_github
User git

Now you can do git clone git@github.com:username/repo.git.

NOTE: Verify that the permissions on IdentityFile are 400.SSH will reject, in a not clearly explicit manner, SSH keys that are too readable. It will just look like a credential rejection. The solution, in this case, is:

chmod 400 ~/.ssh/id_rsa_github

https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html

Step 1. Ensure you have an SSH client installed

SSH should be included with the version of Git you installed. To make sure, do the following to verify your installation:

  1. From the Git Bash window, enter the following command to verify that SSH client is available:

    $ ssh -v 
    OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
    usage: ssh [-1246AaCfgkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]
    [-D [bind_address:]port] [-e escape_char] [-F configfile]
    [-i identity_file] [-L [bind_address:]port:host:hostport]
    [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
    [-R [bind_address:]port:host:hostport] [-S ctl_path]
    [-w local_tun[:remote_tun]] [user@]hostname [command]

    If you have ssh installed, the terminal returns version information.

    If you don't have ssh installed, install it now with your package manager.

  2. List the contents of your ~/.ssh directory.
    If you have not used SSH on Git Bash yet, you might see something like this:

    $ ls -a ~/.ssh 
    ls: /c/Users/emmap1/.ssh: No such file or directory

    If you have a default identity already, you'll see two id_* files:

    $ ls -a ~/.ssh 
    .    ..    id_rsa    id_rsa.pub  known_hosts

    In this case, the default identity uses RSA encryption (id_rsa.pub). If you want to use an existing default identity for your Bitbucket account, skip the next section and go to create a config file.

Step 2. Set up your default identity

By default, the system adds keys for all identities to the /Users/<yourname>/.ssh directory. The following procedure creates a default identity.

  1. Open a terminal in your local system.
  2. Enter ssh-keygen at the command line. 
    The command prompts you for a file to save the key in:

    $ ssh-keygen 
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/Users/emmap1/.ssh/id_rsa):
  3. Press enter to accept the default key and path, /c/Users/<yourname>/.ssh/id_rsa, or you can create a key with another name.
    To create a key with a name other than the default, specify the full path to the key. For example, to create a key called my-new-ssh-key, you would enter a path like this at the prompt:

    $ ssh-keygen 
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/Documents and Settings/emmap1/.ssh/id_rsa): /c/Users/emmap1/My Documents/keys/my-new-ssh-key
  4. Enter and renter a passphrase when prompted.
    Unless you need a key for a process such as script, you should always provide a passphrase. 
    The command creates your default identity with its public and private keys. The whole interaction looks similar to the following:

    $ ssh-keygen 
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/Users/emmap1/.ssh/id_rsa):
    Created directory '/c/Users/emmap1/.ssh'.
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /c/Users/emmap1/.ssh/id_rsa.
    Your public key has been saved in /c/Users/emmap1/.ssh/id_rsa.pub.
    The key fingerprint is: e7:94:d1:a3:02:ee:38:6e:a4:5e:26:a3:a9:f4:95:d4 emmap1@EMMA-PC
  5. List the contents of ~/.ssh to view the key files.
    You should see something like the following:

    $ ls ~/.ssh 
    id_rsa id_rsa.pub

    The command created two files, one for the public key (for example id_rsa.pub) and one for the private key (for example, id_rsa).

Step 3. Create a SSH config file

  1. Using your favorite text editor, create a new file (at ~/.ssh/config) or edit the file if it already exists.

  2. Add an entry to the configuration file using the following format:

     
     
     
     
     
    1
    Host bitbucket.org
    2
     IdentityFile ~/.ssh/<privatekeyfile>
     
     

    The second line is indented. That indentation (a single space) is important, so make sure you include it. The second line is the location of your private key file.  If you are following along with these instructions, enter id_rsa for<privatekeyfile>.

    When you are done editing, your configuration looks similar to the following:

     
     
     
     
     
    1
    Host bitbucket.org
    2
     IdentityFile ~/.ssh/id_rsa
     
     
  3. Save and close the file.
  4. Restart the GitBash terminal.

最新文章

  1. VS2010快捷键设置
  2. 2016读书List
  3. 【学习笔记&amp;训练记录】数位DP
  4. 根据id设置、获取元素的文本和value
  5. ASP.NET中常用方法
  6. 用Javascript评估用户输入密码的强度
  7. c++中可以对类中私有成员中的静态变量初始化吗?
  8. 关于go语言的通道
  9. 内部类、异常以及 LeetCode 每日一题
  10. [dev] 啥是Virtual Private Network
  11. JavaScript--fullPage.js插件
  12. Bootstrap3.0学习第四轮(排版)
  13. 使用RegisterNatives注冊原生代码
  14. 2018.11.07 hdu1465不容易系列之一(二项式反演)
  15. C++ Error: error LNK2019: unresolved external symbol
  16. 个人作业2——WordCount
  17. github高效搜索使用总结
  18. android中的style部分属性值介绍 --zz
  19. jquery获取html元素的绝对位置和相对位置的方法
  20. springboot中 简单的SpringMvc全局异常处理

热门文章

  1. 【BZOJ】【1018】【SHOI2008】堵塞的交通traffic
  2. 响应式设计Responsinator工具推荐
  3. Using Hooks
  4. 1051: [HAOI2006]受欢迎的牛
  5. c# 发送消息到Email
  6. HDU5008 Boring String Problem(后缀数组)
  7. acdream1116 Gao the string!(hash二分 or 后缀数组)
  8. POJ 1503 Integer Inquiry(大数相加,java)
  9. 取得DisplayMerics手机屏幕大小的应用
  10. ZOJ 2588 Burning Bridges (tarjan求割边)