【GitHub】PullやPushでパスワードを聞かれないように設定する
~/.ssh/id_rsa(秘密鍵)と~/.ssh/id_rsa.pub(公開鍵)を作る
> ssh-keygen -t rsa
~/.ssh/id_rsa
と~/.ssh/id_rsa.pub
が生成される
GitHubに登録する
Settings > SSH and GPG kers > SSH keys > New SSH key
に~/.ssh/id_rsa.pub
の内容を貼り付ける
- 接続の確認
> ssh -T git@github.com Hi tamago324! You've successfully authenticated, but GitHub does not provide shell access.
ローカルリポジトリの設定を変更する
GitHubのリポジトリのClone or download
のUse SSH
のテキストをコピーし、以下のコマンドを実行する
> git remote set-url origin xxxxxx
秘密鍵のパスを指定する( ~/.ssh/config
の作成)
秘密鍵を以下のように生成した場合
> ssh-keygen -t rsa -f ~/.ssh/id_rsa_github
以下のような~/.ssh/config
を作成する(全く同じ記述で作成する)
Host github github.com HostName github.com IdentityFile ~/.ssh/id_rsa_github User git
接続の確認
> ssh -T git@github.com Hi tamago324! You've successfully authenticated, but GitHub does not provide shell access.