Open ucan-lab opened 6 years ago
GitHubアカウントの認証を省略するためにSSH鍵を設定します。 複数マシンを使用している場合は各マシンで鍵を登録した方がセキュリティ的に良いでしょう。
GitHub用の鍵を作成する。(パスフレーズなし)
$ ssh-keygen -t rsa -b 4096 -N "" -f ~/.ssh/github
~/.ssh/github
~/.ssh/github.pub
-t
-b
-f
~/.ssh/id_rsa
-N
""
* クリップボードに公開鍵をコピー $ cat ~/.ssh/github.pub
https://github.com/settings/ssh/new
cat ~/.ssh/github.pub
$ vim ~/.ssh/config Host github.com User git Port 22 Hostname github.com IdentityFile ~/.ssh/github TCPKeepAlive yes IdentitiesOnly yes UserKnownHostsFile /dev/null StrictHostKeyChecking no
StrictHostKeyChecking no
UserKnownHostsFile#/dev/null
ServerAliveInterval 15
ServerAliveCountMax 10
AddKeysToAgent yes
UseKeychain yes
$ ssh -T github.com Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.
successfully のメッセージが出ていればok
successfully
GitHubアカウントの認証を省略するためにSSH鍵を設定します。 複数マシンを使用している場合は各マシンで鍵を登録した方がセキュリティ的に良いでしょう。
手順
1. GitHub用の秘密鍵、公開鍵を作成
GitHub用の鍵を作成する。(パスフレーズなし)
~/.ssh/github
: 秘密鍵~/.ssh/github.pub
: 公開鍵-t
: 鍵の種類を選択。rsaがデフォルトなので指定の必要はない-b
: ビット数(鍵長)を指定する。デフォルトだと鍵長は2048bit。-f
: ファイル名を指定。デフォルトだと~/.ssh/id_rsa
-N
: パスフレーズの指定。""
と指定することでパスフレーズなしにしている2. GitHubに公開鍵を登録
https://github.com/settings/ssh/new
cat ~/.ssh/github.pub
で表示された文字列をそのまま貼り付け~/.ssh/config へ追記
StrictHostKeyChecking no
ホストキーチェック回避UserKnownHostsFile#/dev/null
ホストキーチェック回避ServerAliveInterval 15
タイムアウト対策ServerAliveCountMax 10
タイムアウト対策AddKeysToAgent yes
毎回パスフレーズを聞かれてくることに対する対策UseKeychain yes
毎回パスフレーズを聞かれてくることに対する対策SSH疎通確認
successfully
のメッセージが出ていればok