Skip to content

Instantly share code, notes, and snippets.

@LeeDDHH
Created September 13, 2021 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LeeDDHH/706e72e4b9958a285ec4a6ae4d2ba1d9 to your computer and use it in GitHub Desktop.
Save LeeDDHH/706e72e4b9958a285ec4a6ae4d2ba1d9 to your computer and use it in GitHub Desktop.
Macからgithubでssh接続するまでにやること

公開鍵、秘密鍵を作成する

$ cd ~
$ mkdir .ssh
$ cd ~/.ssh
$ ssh-keygen -t rsa

公開鍵をGitHubに登録する

  • GitHubアカウントのSSH and GPG keysページにアクセスする
  • New SSH key をクリック
  • title にわかりやすい公開鍵名を入れる
  • key に公開鍵の中身を入れる
    • pbcopy < ~/.ssh/id_rsa.pub で鍵の中身をクリップボードにコピーできる

config ファイルで設定を書く

$ touch ~/.ssh/config
$ vi config

# 以下の内容を入れる

Host *
  AddKeysToAgent yes
  UseKeychain yes

Host github
  HostName github.com
  IdentityFile ~/.ssh/id_rsa
  User git

接続を確認する

  • $ ssh -T git@github.com
    • Hi アカウント名! You've successfully authenticated, but GitHub does not provide shell access. と表示されればOK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment