LoginSignup
0
0

More than 3 years have passed since last update.

GitHubでssh鍵を設定しリポジトリをクローンする(macOS)

Last updated at Posted at 2019-09-18

目的

  • 自身の備忘のために本ページを記述する。

ゴール

  • macOS上で公開鍵・秘密鍵を作成し、GitHubに設定、git clone ssh://...ができるようにする!

手順

  • ホームディレクトリに.sshがなければ作成する(今回はあったのでスキップ)
hogehogenoiMac:~ hogehoge$ cd .ssh
hogehogenoiMac:.ssh hogehoge$ ls
known_hosts
  • 鍵を作成する。
hogehogenoiMac:.ssh hogehoge$ ssh-keygen -t rsa -b 4096 -C "(メールアドレス)"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/hogehoge/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/hogehoge/.ssh/id_rsa.
Your public key has been saved in /Users/hogehoge/.ssh/id_rsa.pub.
  • Githubの鍵設定の箇所にid_rsa.pubの内容を貼り付ける。
    スクリーンショット 2019-09-18 10.41.09.png

  • 動作確認

hogehogenoiMac:repos hogehoge$ ssh -T git@github.com
# known_hostsに追加するか聞かれるので、yesを入力する
...
Hi (ユーザ名)! You've successfully authenticated, but GitHub does not provide shell access.
  • git clone
hogehogenoiMac:repos hogehoge$ git clone git@github.com:(ユーザ名)/prj.git
Cloning into 'prj'...
...
Receiving objects: 100% (3/3), done.

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0