アウトプットログ

チラシの裏からの脱出に向かう線形のブログ

備忘ログ Cloud9 とGithub 公開鍵設定方法

Git飼い慣らし週間の記録。

前回ログ(下記)の解決方法についてメモ。

The authenticity of host 'github.com (192.30.253.112)' can't be established.
RSA key fingerprint is SHxxxxxxxxxxxxxxxxxxxxxxxxxxx.
RSA key fingerprint is MDxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Mac OSSierra以降、githubSSH鍵が毎回設定しないといけないような仕様になってしまったという文章を発見しました。回避方法について、Githubの文書内にもこちらに記載あり。ただあくまでローカル環境の設定方法なので、こちらは追って対処。

***Cloud9からGitHubにアクセスできるよう、公開鍵を登録します。

  1. Cloud9 の環境上でSSH鍵を作成する。
$ cd ~/.ssh
$ ssh-keygen -t rsa -b 4096 -C "xxxxx@email.com" (自分のメアド)

何か色々聞いてくれますが、とりあえずブランクでエンターを3回押せば2つの鍵が生成されます:

別の名前で鍵を作成したい場合は1つ目の問いの箇所で下記のように設定する

Enter file in which to save the key (/Users/(username)/.ssh/id_rsa):id_rsa_github

作成した公開鍵を表示させてみて、コピペする

$ cat ~/.ssh/id_rsa.pub
ssh-rsa XXXXXXXXXXXXXXXXXXXXXXX(4行ぐらいの暗号みたいな文字羅列) xxxx@email.com (先に指定したメアド)

Githubのアカウントで、Settingを開いてSSH and GPG keysを選択 New SSH Keyをクリック、Titleに適当な名前をつけ、Keyの箇所に、上記ssh-rsaを含めメールアドレスが始まる前までをペースト、Add SSH Key ボタンを押す。

-->設定できたらメールも来る

GitHub上でリポジトリを作成し、作成できたらそのリポジトリに書かれているコードを打ち込んでいけばgit push -u origin masterで全てのデータが保存される。