
はじめに
Heroku のリモートリポジトリに git でアクセスしようとした際に、Username を求められました。通常は passphrase を求められるだけなので、Username なんてあったっけ?という状態です。というわけで何を入力すべきか不明だし、実際何を入力してもエラーになるようでした。
下記は git fetch 実行時に Unsername を求められて Email アドレスを入力してみた例です。
1 2 3 4 5 6 7 8 9 10 11 12 |
$ git fetch --all Fetching origin Enter passphrase for key '/home/jade/.ssh/id_rsa': Fetching heroku Username for 'https://git.heroku.com': jadexxxx@gmail.com Password for 'https://jadexxxx@gmail.com@git.heroku.com': remote: ! WARNING: remote: ! Do not authenticate with username and password using git. remote: ! Run `heroku login` to update your credentials, then retry the git command. remote: ! See documentation for details: https://devcenter.heroku.com/articles/git#http-git-authentication fatal: Authentication failed for 'https://git.heroku.com/yyyyyyyyyy.git/' error: Could not fetch heroku |
解決
Heroku はログインすることによって ~/.netrc にログイン情報を書き込んでいるため、ログアウトした場合などで、~/.netrc の内容が不適切になると上記現象が発生するようです。
結論解決するには、ログインし直せば良いです。(というか、今回は私の認識不足で、Heroku をログアウトしてしまっていたようです。)
下記では、一旦ログアウトして再度ログインすることによって、Email アドレスとパスワードでログインできました。その後は、git fetch では passphrase のみを求められていますので、リモートリポジトリへアクセスできました。
1 2 3 4 5 6 7 8 9 10 11 12 |
$ heroku logout Logging out... done $ heroku login heroku: Enter your login credentials Email: jadexxxx@gmail.com Password: ********* Logged in as jadexxxx@gmail.com $ git fetch --all Fetching origin Enter passphrase for key '/home/jade/.ssh/id_rsa': Fetching heroku $ |
なお、ここ大事一度ログインしたらログアウトしない限り、PC を再起動後でもわざわざログインする必要はないので、通常は開発環境で Heroku をログアウトする必要はないと思われます。