ucan-lab / tips

5 stars 0 forks source link

GitHubへ公開鍵を登録し、Macに秘密鍵を登録する #2

Open ucan-lab opened 6 years ago

ucan-lab commented 6 years ago

42 Git初期設定はこちら

GitHubアカウントの認証を省略するためにSSH鍵を設定します。 複数マシンを使用している場合は各マシンで鍵を登録した方がセキュリティ的に良いでしょう。

手順

  1. GitHub用の秘密鍵、公開鍵を作成
  2. GitHubに公開鍵を登録

1. GitHub用の秘密鍵、公開鍵を作成

GitHub用の鍵を作成する。(パスフレーズなし)

$ ssh-keygen -t ed25519 -N "" -f ~/.ssh/github -C sample@example.com

2. GitHubに公開鍵を登録

https://github.com/settings/keys

* クリップボードに公開鍵をコピー
$ pbcopy < ~/.ssh/github.pub

~/.ssh/config へ追記

$ vim ~/.ssh/config
Host *
  StrictHostKeyChecking no
  UserKnownHostsFile=/dev/null
  ServerAliveInterval 15
  ServerAliveCountMax 30
  AddKeysToAgent yes
  UseKeychain yes
  IdentitiesOnly yes

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

SSH疎通確認

$ ssh -T github.com
Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.

successfully のメッセージが出ていればok