Vagrant上でのディレクトリを初めてgit pushする
ぜひフォローしてください
Follow @SoYaNoNikkeyVirtualBox, Vagrant を使った仮想環境で作成したものをGithubにgit pushしようとしたら、
*** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: empty ident name (for <vagrant@ubuntu-xenial.(none)>) not allowed
名を名乗るのを忘れていたので、指示通りにメールアドレスと名前を登録
$ git config --global user.email "hoge@hoge.com" $ git config --global user.name "huga"
これでいけるやろと思ってコミットしたら、
Warning: Permanently added 'github.com,192.30.255.112' (RSA) to the list of known h osts. Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
ここで気づいた。 いくら1台のパソコン上とはいえ仮想環境上でのUbuntuからアクセスしているので、母艦(mac)とは別口でSSHの設定をしなければならないということに。
そりゃそうだ。
$ ls ~/.ssh authorized_keys known_hosts
当然SSH公開鍵を保存しているid_rsa.pubはなかったので
$ ssh-keygen -t rsa -C "hoge@hoge.com"
作成されたid_rsa.pubをvimで開いてコピー。
Githubの右上の自分のアイコンからSettingsを開いて
'SSH and GPG keys'ページを開いて'New SSH key'を選択。
先ほどコピーしたSSH公開鍵をペースト。
これで完了。
まとめ
- vagrantで仮想環境を立ち上げる=別のパソコンを立ち上げる
- つまりSSH公開鍵を新たに作成しないとダメよ
- 同じ過ちは繰り返さないようにしよう