Skip to content

Instantly share code, notes, and snippets.

@gotraveltoworld
Last active August 30, 2017 06:57
Show Gist options
  • Save gotraveltoworld/55b4a91a5238fc2fae8cd101d0728e2f to your computer and use it in GitHub Desktop.
Save gotraveltoworld/55b4a91a5238fc2fae8cd101d0728e2f to your computer and use it in GitHub Desktop.
Set single SSH key & multi-SSH keys for GitHub

Set single SSH key & multi-SSH keys for GitHub

Date : 2017/08/30.


Steps

  1. Create GitHub account.
  2. Generate SSH key.
    ssh-keygen -t rsa -b 4096 -C "name@xxx.com" -f github
  3. Look and copy SSH public key.
    cat ~/.ssh/github.pub
  4. Import SSH public key on GitHub.
    1. copy the public key(plain text)
    2. paste the public key on Github settings page.
  5. Checking SSH connection.
    # base syntax
    ssh -T user@hostname
    # example
    ssh -T git@github.com
    # self-defined host name
    ssh -T git@github.com-hello
    If connection is ok, you can see Hi (your name)! You've successfully authenticated, but GitHub does not provide shell access.
  6. If you need to set multi SSH keys, you can try to add config file.
    touch ~/.ssh/config
    vi ~/.ssh/config
    And then you can add below configure into the config file.
    Host git@github.com-hello
    HostName github.com
    User git
    IdentityFile ~/.ssh/github

Reference

  1. GitHub設定指引
  2. SSH Keys for GitHub
  3. 多重 SSH Keys 與 Github 帳號
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment