0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

gitの鍵とは

Last updated at Posted at 2019-12-13

gitの鍵とは

自分のgithubをいじる時はパスワードやユーザーネームは入力しない。

でも他人に自分のリモートリポジトリをめちゃめちゃにされたら困る。

そこで出てくるのが公開鍵と秘密鍵!

鍵には

公開鍵

秘密鍵

の2種類がある。

公開鍵は、githubに送って、秘密鍵は自分のパソコンの中にある。
この鍵が一致することで、本人確認ができてgit hubをいじることができる。

$cd ~/.ssh

これで鍵を作成するディレクトリに移動する

ssh-keygen

で鍵をつくる
すると以下のようなのが出てくる

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/xxx.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
id_rsa.pub

これが公開鍵

id_rsa

これが秘密鍵

次に

$ pbcopy < ~/.ssh/id_rsa.pub

これを実行すると超長い鍵がコピーされるので、githubの鍵を貼るところに貼り付ける

ssh git@github.com

最後にこれを実行してHi!って返ってきたらおっけー!

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?